Coverage Report

Created: 2026-10-17 06:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/lzo-2.10/src/lzo_mchw.ch
Line
Count
Source
1
/* lzo_mchw.ch -- matching functions using a window
2
3
   This file is part of the LZO real-time data compression library.
4
5
   Copyright (C) 1996-2017 Markus Franz Xaver Johannes Oberhumer
6
   All Rights Reserved.
7
8
   The LZO library is free software; you can redistribute it and/or
9
   modify it under the terms of the GNU General Public License as
10
   published by the Free Software Foundation; either version 2 of
11
   the License, or (at your option) any later version.
12
13
   The LZO library is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
18
   You should have received a copy of the GNU General Public License
19
   along with the LZO library; see the file COPYING.
20
   If not, write to the Free Software Foundation, Inc.,
21
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23
   Markus F.X.J. Oberhumer
24
   <markus@oberhumer.com>
25
   http://www.oberhumer.com/opensource/lzo/
26
 */
27
28
29
/***********************************************************************
30
//
31
************************************************************************/
32
33
typedef struct
34
{
35
    unsigned init;
36
37
    lzo_uint look;          /* bytes in lookahead buffer */
38
39
    lzo_uint m_len;
40
    lzo_uint m_off;
41
42
    lzo_uint last_m_len;
43
    lzo_uint last_m_off;
44
45
    const lzo_bytep bp;
46
    const lzo_bytep ip;
47
    const lzo_bytep in;
48
    const lzo_bytep in_end;
49
    lzo_bytep out;
50
51
    lzo_callback_p cb;
52
53
    lzo_uint textsize;      /* text size counter */
54
    lzo_uint codesize;      /* code size counter */
55
    lzo_uint printcount;    /* counter for reporting progress every 1K bytes */
56
57
    /* some stats */
58
    lzo_uint lit_bytes;
59
    lzo_uint match_bytes;
60
    lzo_uint rep_bytes;
61
    lzo_uint lazy;
62
63
#if defined(LZO1B)
64
    lzo_uint r1_m_len;
65
66
    /* some stats */
67
    lzo_uint r1_r, m3_r, m2_m, m3_m;
68
#endif
69
70
#if defined(LZO1C)
71
    lzo_uint r1_m_len;
72
    lzo_bytep m3;
73
74
    /* some stats */
75
    lzo_uint r1_r, m3_r, m2_m, m3_m;
76
#endif
77
78
#if defined(LZO1F)
79
    lzo_uint r1_lit;
80
    lzo_uint r1_m_len;
81
82
    /* some stats */
83
    lzo_uint r1_r, m2_m, m3_m;
84
#endif
85
86
#if defined(LZO1X) || defined(LZO1Y) || defined(LZO1Z)
87
    lzo_uint r1_lit;
88
    lzo_uint r1_m_len;
89
90
    /* some stats */
91
    lzo_uint m1a_m, m1b_m, m2_m, m3_m, m4_m;
92
    lzo_uint lit1_r, lit2_r, lit3_r;
93
#endif
94
95
#if defined(LZO2A)
96
    /* some stats */
97
    lzo_uint m1, m2, m3, m4;
98
#endif
99
}
100
LZO_COMPRESS_T;
101
102
103
152M
#define getbyte(c)  ((c).ip < (c).in_end ? *((c).ip)++ : (-1))
104
105
#include "lzo_swd.ch"
106
107
108
/***********************************************************************
109
//
110
************************************************************************/
111
112
static int
113
init_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
114
             const lzo_bytep dict, lzo_uint dict_len,
115
             lzo_uint32_t flags )
116
7.38k
{
117
7.38k
    int r;
118
119
7.38k
    assert(!c->init);
120
7.38k
    c->init = 1;
121
122
7.38k
    s->c = c;
123
124
7.38k
    c->last_m_len = c->last_m_off = 0;
125
126
7.38k
    c->textsize = c->codesize = c->printcount = 0;
127
7.38k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
7.38k
    c->lazy = 0;
129
130
7.38k
    r = swd_init(s,dict,dict_len);
131
7.38k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
7.38k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
7.38k
    return LZO_E_OK;
139
7.38k
}
lzo1b_9x.c:init_match
Line
Count
Source
116
657
{
117
657
    int r;
118
119
657
    assert(!c->init);
120
657
    c->init = 1;
121
122
657
    s->c = c;
123
124
657
    c->last_m_len = c->last_m_off = 0;
125
126
657
    c->textsize = c->codesize = c->printcount = 0;
127
657
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
657
    c->lazy = 0;
129
130
657
    r = swd_init(s,dict,dict_len);
131
657
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
657
    s->use_best_off = (flags & 1) ? 1 : 0;
138
657
    return LZO_E_OK;
139
657
}
lzo1c_9x.c:init_match
Line
Count
Source
116
712
{
117
712
    int r;
118
119
712
    assert(!c->init);
120
712
    c->init = 1;
121
122
712
    s->c = c;
123
124
712
    c->last_m_len = c->last_m_off = 0;
125
126
712
    c->textsize = c->codesize = c->printcount = 0;
127
712
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
712
    c->lazy = 0;
129
130
712
    r = swd_init(s,dict,dict_len);
131
712
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
712
    s->use_best_off = (flags & 1) ? 1 : 0;
138
712
    return LZO_E_OK;
139
712
}
lzo1f_9x.c:init_match
Line
Count
Source
116
820
{
117
820
    int r;
118
119
820
    assert(!c->init);
120
820
    c->init = 1;
121
122
820
    s->c = c;
123
124
820
    c->last_m_len = c->last_m_off = 0;
125
126
820
    c->textsize = c->codesize = c->printcount = 0;
127
820
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
820
    c->lazy = 0;
129
130
820
    r = swd_init(s,dict,dict_len);
131
820
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
820
    s->use_best_off = (flags & 1) ? 1 : 0;
138
820
    return LZO_E_OK;
139
820
}
lzo1x_9x.c:init_match
Line
Count
Source
116
1.39k
{
117
1.39k
    int r;
118
119
1.39k
    assert(!c->init);
120
1.39k
    c->init = 1;
121
122
1.39k
    s->c = c;
123
124
1.39k
    c->last_m_len = c->last_m_off = 0;
125
126
1.39k
    c->textsize = c->codesize = c->printcount = 0;
127
1.39k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.39k
    c->lazy = 0;
129
130
1.39k
    r = swd_init(s,dict,dict_len);
131
1.39k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.39k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.39k
    return LZO_E_OK;
139
1.39k
}
lzo1y_9x.c:init_match
Line
Count
Source
116
1.41k
{
117
1.41k
    int r;
118
119
1.41k
    assert(!c->init);
120
1.41k
    c->init = 1;
121
122
1.41k
    s->c = c;
123
124
1.41k
    c->last_m_len = c->last_m_off = 0;
125
126
1.41k
    c->textsize = c->codesize = c->printcount = 0;
127
1.41k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.41k
    c->lazy = 0;
129
130
1.41k
    r = swd_init(s,dict,dict_len);
131
1.41k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.41k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.41k
    return LZO_E_OK;
139
1.41k
}
lzo1z_9x.c:init_match
Line
Count
Source
116
1.65k
{
117
1.65k
    int r;
118
119
1.65k
    assert(!c->init);
120
1.65k
    c->init = 1;
121
122
1.65k
    s->c = c;
123
124
1.65k
    c->last_m_len = c->last_m_off = 0;
125
126
1.65k
    c->textsize = c->codesize = c->printcount = 0;
127
1.65k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.65k
    c->lazy = 0;
129
130
1.65k
    r = swd_init(s,dict,dict_len);
131
1.65k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.65k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.65k
    return LZO_E_OK;
139
1.65k
}
lzo2a_9x.c:init_match
Line
Count
Source
116
731
{
117
731
    int r;
118
119
731
    assert(!c->init);
120
731
    c->init = 1;
121
122
731
    s->c = c;
123
124
731
    c->last_m_len = c->last_m_off = 0;
125
126
731
    c->textsize = c->codesize = c->printcount = 0;
127
731
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
731
    c->lazy = 0;
129
130
731
    r = swd_init(s,dict,dict_len);
131
731
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
731
    s->use_best_off = (flags & 1) ? 1 : 0;
138
731
    return LZO_E_OK;
139
731
}
140
141
142
/***********************************************************************
143
//
144
************************************************************************/
145
146
static int
147
find_match ( LZO_COMPRESS_T *c, lzo_swd_p s,
148
             lzo_uint this_len, lzo_uint skip )
149
77.2M
{
150
77.2M
    assert(c->init);
151
152
77.2M
    if (skip > 0)
153
3.53M
    {
154
3.53M
        assert(this_len >= skip);
155
3.53M
        swd_accept(s, this_len - skip);
156
3.53M
        c->textsize += this_len - skip + 1;
157
3.53M
    }
158
73.7M
    else
159
73.7M
    {
160
73.7M
        assert(this_len <= 1);
161
73.7M
        c->textsize += this_len - skip;
162
73.7M
    }
163
164
77.2M
    s->m_len = SWD_THRESHOLD;
165
77.2M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
42.8M
    if (s->use_best_off)
168
42.8M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
77.2M
    swd_findbest(s);
171
77.2M
    c->m_len = s->m_len;
172
77.2M
    c->m_off = s->m_off;
173
174
77.2M
    swd_getbyte(s);
175
176
77.2M
    if (s->b_char < 0)
177
7.38k
    {
178
7.38k
        c->look = 0;
179
7.38k
        c->m_len = 0;
180
7.38k
        swd_exit(s);
181
7.38k
    }
182
77.2M
    else
183
77.2M
    {
184
77.2M
        c->look = s->look + 1;
185
77.2M
    }
186
77.2M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
77.2M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
77.2M
    return LZO_E_OK;
219
77.2M
}
lzo1b_9x.c:find_match
Line
Count
Source
149
4.75M
{
150
4.75M
    assert(c->init);
151
152
4.75M
    if (skip > 0)
153
148k
    {
154
148k
        assert(this_len >= skip);
155
148k
        swd_accept(s, this_len - skip);
156
148k
        c->textsize += this_len - skip + 1;
157
148k
    }
158
4.60M
    else
159
4.60M
    {
160
4.60M
        assert(this_len <= 1);
161
4.60M
        c->textsize += this_len - skip;
162
4.60M
    }
163
164
4.75M
    s->m_len = SWD_THRESHOLD;
165
4.75M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
    if (s->use_best_off)
168
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
4.75M
    swd_findbest(s);
171
4.75M
    c->m_len = s->m_len;
172
4.75M
    c->m_off = s->m_off;
173
174
4.75M
    swd_getbyte(s);
175
176
4.75M
    if (s->b_char < 0)
177
657
    {
178
657
        c->look = 0;
179
657
        c->m_len = 0;
180
657
        swd_exit(s);
181
657
    }
182
4.74M
    else
183
4.74M
    {
184
4.74M
        c->look = s->look + 1;
185
4.74M
    }
186
4.75M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
4.75M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
4.75M
    return LZO_E_OK;
219
4.75M
}
lzo1c_9x.c:find_match
Line
Count
Source
149
7.67M
{
150
7.67M
    assert(c->init);
151
152
7.67M
    if (skip > 0)
153
91.0k
    {
154
91.0k
        assert(this_len >= skip);
155
91.0k
        swd_accept(s, this_len - skip);
156
91.0k
        c->textsize += this_len - skip + 1;
157
91.0k
    }
158
7.58M
    else
159
7.58M
    {
160
7.58M
        assert(this_len <= 1);
161
7.58M
        c->textsize += this_len - skip;
162
7.58M
    }
163
164
7.67M
    s->m_len = SWD_THRESHOLD;
165
7.67M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
    if (s->use_best_off)
168
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
7.67M
    swd_findbest(s);
171
7.67M
    c->m_len = s->m_len;
172
7.67M
    c->m_off = s->m_off;
173
174
7.67M
    swd_getbyte(s);
175
176
7.67M
    if (s->b_char < 0)
177
712
    {
178
712
        c->look = 0;
179
712
        c->m_len = 0;
180
712
        swd_exit(s);
181
712
    }
182
7.67M
    else
183
7.67M
    {
184
7.67M
        c->look = s->look + 1;
185
7.67M
    }
186
7.67M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
7.67M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
7.67M
    return LZO_E_OK;
219
7.67M
}
lzo1f_9x.c:find_match
Line
Count
Source
149
15.5M
{
150
15.5M
    assert(c->init);
151
152
15.5M
    if (skip > 0)
153
115k
    {
154
115k
        assert(this_len >= skip);
155
115k
        swd_accept(s, this_len - skip);
156
115k
        c->textsize += this_len - skip + 1;
157
115k
    }
158
15.4M
    else
159
15.4M
    {
160
15.4M
        assert(this_len <= 1);
161
15.4M
        c->textsize += this_len - skip;
162
15.4M
    }
163
164
15.5M
    s->m_len = SWD_THRESHOLD;
165
15.5M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
    if (s->use_best_off)
168
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
15.5M
    swd_findbest(s);
171
15.5M
    c->m_len = s->m_len;
172
15.5M
    c->m_off = s->m_off;
173
174
15.5M
    swd_getbyte(s);
175
176
15.5M
    if (s->b_char < 0)
177
820
    {
178
820
        c->look = 0;
179
820
        c->m_len = 0;
180
820
        swd_exit(s);
181
820
    }
182
15.5M
    else
183
15.5M
    {
184
15.5M
        c->look = s->look + 1;
185
15.5M
    }
186
15.5M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
15.5M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
15.5M
    return LZO_E_OK;
219
15.5M
}
lzo1x_9x.c:find_match
Line
Count
Source
149
11.3M
{
150
11.3M
    assert(c->init);
151
152
11.3M
    if (skip > 0)
153
799k
    {
154
799k
        assert(this_len >= skip);
155
799k
        swd_accept(s, this_len - skip);
156
799k
        c->textsize += this_len - skip + 1;
157
799k
    }
158
10.5M
    else
159
10.5M
    {
160
10.5M
        assert(this_len <= 1);
161
10.5M
        c->textsize += this_len - skip;
162
10.5M
    }
163
164
11.3M
    s->m_len = SWD_THRESHOLD;
165
11.3M
    s->m_off = 0;
166
11.3M
#ifdef SWD_BEST_OFF
167
11.3M
    if (s->use_best_off)
168
11.3M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
11.3M
#endif
170
11.3M
    swd_findbest(s);
171
11.3M
    c->m_len = s->m_len;
172
11.3M
    c->m_off = s->m_off;
173
174
11.3M
    swd_getbyte(s);
175
176
11.3M
    if (s->b_char < 0)
177
1.39k
    {
178
1.39k
        c->look = 0;
179
1.39k
        c->m_len = 0;
180
1.39k
        swd_exit(s);
181
1.39k
    }
182
11.3M
    else
183
11.3M
    {
184
11.3M
        c->look = s->look + 1;
185
11.3M
    }
186
11.3M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
11.3M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
11.3M
    return LZO_E_OK;
219
11.3M
}
lzo1y_9x.c:find_match
Line
Count
Source
149
17.8M
{
150
17.8M
    assert(c->init);
151
152
17.8M
    if (skip > 0)
153
662k
    {
154
662k
        assert(this_len >= skip);
155
662k
        swd_accept(s, this_len - skip);
156
662k
        c->textsize += this_len - skip + 1;
157
662k
    }
158
17.1M
    else
159
17.1M
    {
160
17.1M
        assert(this_len <= 1);
161
17.1M
        c->textsize += this_len - skip;
162
17.1M
    }
163
164
17.8M
    s->m_len = SWD_THRESHOLD;
165
17.8M
    s->m_off = 0;
166
17.8M
#ifdef SWD_BEST_OFF
167
17.8M
    if (s->use_best_off)
168
17.8M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
17.8M
#endif
170
17.8M
    swd_findbest(s);
171
17.8M
    c->m_len = s->m_len;
172
17.8M
    c->m_off = s->m_off;
173
174
17.8M
    swd_getbyte(s);
175
176
17.8M
    if (s->b_char < 0)
177
1.41k
    {
178
1.41k
        c->look = 0;
179
1.41k
        c->m_len = 0;
180
1.41k
        swd_exit(s);
181
1.41k
    }
182
17.8M
    else
183
17.8M
    {
184
17.8M
        c->look = s->look + 1;
185
17.8M
    }
186
17.8M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
17.8M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
17.8M
    return LZO_E_OK;
219
17.8M
}
lzo1z_9x.c:find_match
Line
Count
Source
149
13.6M
{
150
13.6M
    assert(c->init);
151
152
13.6M
    if (skip > 0)
153
917k
    {
154
917k
        assert(this_len >= skip);
155
917k
        swd_accept(s, this_len - skip);
156
917k
        c->textsize += this_len - skip + 1;
157
917k
    }
158
12.7M
    else
159
12.7M
    {
160
12.7M
        assert(this_len <= 1);
161
12.7M
        c->textsize += this_len - skip;
162
12.7M
    }
163
164
13.6M
    s->m_len = SWD_THRESHOLD;
165
13.6M
    s->m_off = 0;
166
13.6M
#ifdef SWD_BEST_OFF
167
13.6M
    if (s->use_best_off)
168
13.6M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
13.6M
#endif
170
13.6M
    swd_findbest(s);
171
13.6M
    c->m_len = s->m_len;
172
13.6M
    c->m_off = s->m_off;
173
174
13.6M
    swd_getbyte(s);
175
176
13.6M
    if (s->b_char < 0)
177
1.65k
    {
178
1.65k
        c->look = 0;
179
1.65k
        c->m_len = 0;
180
1.65k
        swd_exit(s);
181
1.65k
    }
182
13.6M
    else
183
13.6M
    {
184
13.6M
        c->look = s->look + 1;
185
13.6M
    }
186
13.6M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
13.6M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
13.6M
    return LZO_E_OK;
219
13.6M
}
lzo2a_9x.c:find_match
Line
Count
Source
149
6.40M
{
150
6.40M
    assert(c->init);
151
152
6.40M
    if (skip > 0)
153
804k
    {
154
804k
        assert(this_len >= skip);
155
804k
        swd_accept(s, this_len - skip);
156
804k
        c->textsize += this_len - skip + 1;
157
804k
    }
158
5.59M
    else
159
5.59M
    {
160
5.59M
        assert(this_len <= 1);
161
5.59M
        c->textsize += this_len - skip;
162
5.59M
    }
163
164
6.40M
    s->m_len = SWD_THRESHOLD;
165
6.40M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
    if (s->use_best_off)
168
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
6.40M
    swd_findbest(s);
171
6.40M
    c->m_len = s->m_len;
172
6.40M
    c->m_off = s->m_off;
173
174
6.40M
    swd_getbyte(s);
175
176
6.40M
    if (s->b_char < 0)
177
731
    {
178
731
        c->look = 0;
179
731
        c->m_len = 0;
180
731
        swd_exit(s);
181
731
    }
182
6.40M
    else
183
6.40M
    {
184
6.40M
        c->look = s->look + 1;
185
6.40M
    }
186
6.40M
    c->bp = c->ip - c->look;
187
188
#if 0
189
    /* brute force match search */
190
    if (c->m_len > SWD_THRESHOLD && c->m_len + 1 <= c->look)
191
    {
192
        const lzo_bytep ip = c->bp;
193
        const lzo_bytep m  = c->bp - c->m_off;
194
        const lzo_bytep in = c->in;
195
196
        if (ip - in > s->swd_n)
197
            in = ip - s->swd_n;
198
        for (;;)
199
        {
200
            while (*in != *ip)
201
                in++;
202
            if (in == ip)
203
                break;
204
            if (in != m)
205
                if (lzo_memcmp(in,ip,c->m_len+1) == 0)
206
                    printf("%p %p %p %5d\n",in,ip,m,c->m_len);
207
            in++;
208
        }
209
    }
210
#endif
211
212
6.40M
    if (c->cb && c->cb->nprogress && c->textsize > c->printcount)
213
0
    {
214
0
        (*c->cb->nprogress)(c->cb, c->textsize, c->codesize, 0);
215
0
        c->printcount += 1024;
216
0
    }
217
218
6.40M
    return LZO_E_OK;
219
6.40M
}
220
221
222
/* vim:set ts=4 sw=4 et: */