Coverage Report

Created: 2025-12-10 06:47

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
142M
#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
5.84k
{
117
5.84k
    int r;
118
119
5.84k
    assert(!c->init);
120
5.84k
    c->init = 1;
121
122
5.84k
    s->c = c;
123
124
5.84k
    c->last_m_len = c->last_m_off = 0;
125
126
5.84k
    c->textsize = c->codesize = c->printcount = 0;
127
5.84k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
5.84k
    c->lazy = 0;
129
130
5.84k
    r = swd_init(s,dict,dict_len);
131
5.84k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
5.84k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
5.84k
    return LZO_E_OK;
139
5.84k
}
lzo1b_9x.c:init_match
Line
Count
Source
116
521
{
117
521
    int r;
118
119
521
    assert(!c->init);
120
521
    c->init = 1;
121
122
521
    s->c = c;
123
124
521
    c->last_m_len = c->last_m_off = 0;
125
126
521
    c->textsize = c->codesize = c->printcount = 0;
127
521
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
521
    c->lazy = 0;
129
130
521
    r = swd_init(s,dict,dict_len);
131
521
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
521
    s->use_best_off = (flags & 1) ? 1 : 0;
138
521
    return LZO_E_OK;
139
521
}
lzo1c_9x.c:init_match
Line
Count
Source
116
587
{
117
587
    int r;
118
119
587
    assert(!c->init);
120
587
    c->init = 1;
121
122
587
    s->c = c;
123
124
587
    c->last_m_len = c->last_m_off = 0;
125
126
587
    c->textsize = c->codesize = c->printcount = 0;
127
587
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
587
    c->lazy = 0;
129
130
587
    r = swd_init(s,dict,dict_len);
131
587
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
587
    s->use_best_off = (flags & 1) ? 1 : 0;
138
587
    return LZO_E_OK;
139
587
}
lzo1f_9x.c:init_match
Line
Count
Source
116
647
{
117
647
    int r;
118
119
647
    assert(!c->init);
120
647
    c->init = 1;
121
122
647
    s->c = c;
123
124
647
    c->last_m_len = c->last_m_off = 0;
125
126
647
    c->textsize = c->codesize = c->printcount = 0;
127
647
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
647
    c->lazy = 0;
129
130
647
    r = swd_init(s,dict,dict_len);
131
647
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
647
    s->use_best_off = (flags & 1) ? 1 : 0;
138
647
    return LZO_E_OK;
139
647
}
lzo1x_9x.c:init_match
Line
Count
Source
116
1.06k
{
117
1.06k
    int r;
118
119
1.06k
    assert(!c->init);
120
1.06k
    c->init = 1;
121
122
1.06k
    s->c = c;
123
124
1.06k
    c->last_m_len = c->last_m_off = 0;
125
126
1.06k
    c->textsize = c->codesize = c->printcount = 0;
127
1.06k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.06k
    c->lazy = 0;
129
130
1.06k
    r = swd_init(s,dict,dict_len);
131
1.06k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.06k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.06k
    return LZO_E_OK;
139
1.06k
}
lzo1y_9x.c:init_match
Line
Count
Source
116
1.05k
{
117
1.05k
    int r;
118
119
1.05k
    assert(!c->init);
120
1.05k
    c->init = 1;
121
122
1.05k
    s->c = c;
123
124
1.05k
    c->last_m_len = c->last_m_off = 0;
125
126
1.05k
    c->textsize = c->codesize = c->printcount = 0;
127
1.05k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.05k
    c->lazy = 0;
129
130
1.05k
    r = swd_init(s,dict,dict_len);
131
1.05k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.05k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.05k
    return LZO_E_OK;
139
1.05k
}
lzo1z_9x.c:init_match
Line
Count
Source
116
1.32k
{
117
1.32k
    int r;
118
119
1.32k
    assert(!c->init);
120
1.32k
    c->init = 1;
121
122
1.32k
    s->c = c;
123
124
1.32k
    c->last_m_len = c->last_m_off = 0;
125
126
1.32k
    c->textsize = c->codesize = c->printcount = 0;
127
1.32k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.32k
    c->lazy = 0;
129
130
1.32k
    r = swd_init(s,dict,dict_len);
131
1.32k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.32k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.32k
    return LZO_E_OK;
139
1.32k
}
lzo2a_9x.c:init_match
Line
Count
Source
116
646
{
117
646
    int r;
118
119
646
    assert(!c->init);
120
646
    c->init = 1;
121
122
646
    s->c = c;
123
124
646
    c->last_m_len = c->last_m_off = 0;
125
126
646
    c->textsize = c->codesize = c->printcount = 0;
127
646
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
646
    c->lazy = 0;
129
130
646
    r = swd_init(s,dict,dict_len);
131
646
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
646
    s->use_best_off = (flags & 1) ? 1 : 0;
138
646
    return LZO_E_OK;
139
646
}
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
55.1M
{
150
55.1M
    assert(c->init);
151
152
55.1M
    if (skip > 0)
153
2.87M
    {
154
2.87M
        assert(this_len >= skip);
155
2.87M
        swd_accept(s, this_len - skip);
156
2.87M
        c->textsize += this_len - skip + 1;
157
2.87M
    }
158
52.2M
    else
159
52.2M
    {
160
52.2M
        assert(this_len <= 1);
161
52.2M
        c->textsize += this_len - skip;
162
52.2M
    }
163
164
55.1M
    s->m_len = SWD_THRESHOLD;
165
55.1M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
36.8M
    if (s->use_best_off)
168
36.8M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
55.1M
    swd_findbest(s);
171
55.1M
    c->m_len = s->m_len;
172
55.1M
    c->m_off = s->m_off;
173
174
55.1M
    swd_getbyte(s);
175
176
55.1M
    if (s->b_char < 0)
177
5.84k
    {
178
5.84k
        c->look = 0;
179
5.84k
        c->m_len = 0;
180
5.84k
        swd_exit(s);
181
5.84k
    }
182
55.0M
    else
183
55.0M
    {
184
55.0M
        c->look = s->look + 1;
185
55.0M
    }
186
55.1M
    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
55.1M
    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
55.1M
    return LZO_E_OK;
219
55.1M
}
lzo1b_9x.c:find_match
Line
Count
Source
149
3.16M
{
150
3.16M
    assert(c->init);
151
152
3.16M
    if (skip > 0)
153
126k
    {
154
126k
        assert(this_len >= skip);
155
126k
        swd_accept(s, this_len - skip);
156
126k
        c->textsize += this_len - skip + 1;
157
126k
    }
158
3.03M
    else
159
3.03M
    {
160
3.03M
        assert(this_len <= 1);
161
3.03M
        c->textsize += this_len - skip;
162
3.03M
    }
163
164
3.16M
    s->m_len = SWD_THRESHOLD;
165
3.16M
    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
3.16M
    swd_findbest(s);
171
3.16M
    c->m_len = s->m_len;
172
3.16M
    c->m_off = s->m_off;
173
174
3.16M
    swd_getbyte(s);
175
176
3.16M
    if (s->b_char < 0)
177
521
    {
178
521
        c->look = 0;
179
521
        c->m_len = 0;
180
521
        swd_exit(s);
181
521
    }
182
3.16M
    else
183
3.16M
    {
184
3.16M
        c->look = s->look + 1;
185
3.16M
    }
186
3.16M
    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
3.16M
    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
3.16M
    return LZO_E_OK;
219
3.16M
}
lzo1c_9x.c:find_match
Line
Count
Source
149
5.70M
{
150
5.70M
    assert(c->init);
151
152
5.70M
    if (skip > 0)
153
150k
    {
154
150k
        assert(this_len >= skip);
155
150k
        swd_accept(s, this_len - skip);
156
150k
        c->textsize += this_len - skip + 1;
157
150k
    }
158
5.55M
    else
159
5.55M
    {
160
5.55M
        assert(this_len <= 1);
161
5.55M
        c->textsize += this_len - skip;
162
5.55M
    }
163
164
5.70M
    s->m_len = SWD_THRESHOLD;
165
5.70M
    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
5.70M
    swd_findbest(s);
171
5.70M
    c->m_len = s->m_len;
172
5.70M
    c->m_off = s->m_off;
173
174
5.70M
    swd_getbyte(s);
175
176
5.70M
    if (s->b_char < 0)
177
587
    {
178
587
        c->look = 0;
179
587
        c->m_len = 0;
180
587
        swd_exit(s);
181
587
    }
182
5.70M
    else
183
5.70M
    {
184
5.70M
        c->look = s->look + 1;
185
5.70M
    }
186
5.70M
    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
5.70M
    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
5.70M
    return LZO_E_OK;
219
5.70M
}
lzo1f_9x.c:find_match
Line
Count
Source
149
5.89M
{
150
5.89M
    assert(c->init);
151
152
5.89M
    if (skip > 0)
153
312k
    {
154
312k
        assert(this_len >= skip);
155
312k
        swd_accept(s, this_len - skip);
156
312k
        c->textsize += this_len - skip + 1;
157
312k
    }
158
5.57M
    else
159
5.57M
    {
160
5.57M
        assert(this_len <= 1);
161
5.57M
        c->textsize += this_len - skip;
162
5.57M
    }
163
164
5.89M
    s->m_len = SWD_THRESHOLD;
165
5.89M
    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
5.89M
    swd_findbest(s);
171
5.89M
    c->m_len = s->m_len;
172
5.89M
    c->m_off = s->m_off;
173
174
5.89M
    swd_getbyte(s);
175
176
5.89M
    if (s->b_char < 0)
177
647
    {
178
647
        c->look = 0;
179
647
        c->m_len = 0;
180
647
        swd_exit(s);
181
647
    }
182
5.88M
    else
183
5.88M
    {
184
5.88M
        c->look = s->look + 1;
185
5.88M
    }
186
5.89M
    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
5.89M
    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
5.89M
    return LZO_E_OK;
219
5.89M
}
lzo1x_9x.c:find_match
Line
Count
Source
149
8.42M
{
150
8.42M
    assert(c->init);
151
152
8.42M
    if (skip > 0)
153
633k
    {
154
633k
        assert(this_len >= skip);
155
633k
        swd_accept(s, this_len - skip);
156
633k
        c->textsize += this_len - skip + 1;
157
633k
    }
158
7.79M
    else
159
7.79M
    {
160
7.79M
        assert(this_len <= 1);
161
7.79M
        c->textsize += this_len - skip;
162
7.79M
    }
163
164
8.42M
    s->m_len = SWD_THRESHOLD;
165
8.42M
    s->m_off = 0;
166
8.42M
#ifdef SWD_BEST_OFF
167
8.42M
    if (s->use_best_off)
168
8.42M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
8.42M
#endif
170
8.42M
    swd_findbest(s);
171
8.42M
    c->m_len = s->m_len;
172
8.42M
    c->m_off = s->m_off;
173
174
8.42M
    swd_getbyte(s);
175
176
8.42M
    if (s->b_char < 0)
177
1.06k
    {
178
1.06k
        c->look = 0;
179
1.06k
        c->m_len = 0;
180
1.06k
        swd_exit(s);
181
1.06k
    }
182
8.42M
    else
183
8.42M
    {
184
8.42M
        c->look = s->look + 1;
185
8.42M
    }
186
8.42M
    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
8.42M
    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
8.42M
    return LZO_E_OK;
219
8.42M
}
lzo1y_9x.c:find_match
Line
Count
Source
149
15.1M
{
150
15.1M
    assert(c->init);
151
152
15.1M
    if (skip > 0)
153
726k
    {
154
726k
        assert(this_len >= skip);
155
726k
        swd_accept(s, this_len - skip);
156
726k
        c->textsize += this_len - skip + 1;
157
726k
    }
158
14.4M
    else
159
14.4M
    {
160
14.4M
        assert(this_len <= 1);
161
14.4M
        c->textsize += this_len - skip;
162
14.4M
    }
163
164
15.1M
    s->m_len = SWD_THRESHOLD;
165
15.1M
    s->m_off = 0;
166
15.1M
#ifdef SWD_BEST_OFF
167
15.1M
    if (s->use_best_off)
168
15.1M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
15.1M
#endif
170
15.1M
    swd_findbest(s);
171
15.1M
    c->m_len = s->m_len;
172
15.1M
    c->m_off = s->m_off;
173
174
15.1M
    swd_getbyte(s);
175
176
15.1M
    if (s->b_char < 0)
177
1.05k
    {
178
1.05k
        c->look = 0;
179
1.05k
        c->m_len = 0;
180
1.05k
        swd_exit(s);
181
1.05k
    }
182
15.1M
    else
183
15.1M
    {
184
15.1M
        c->look = s->look + 1;
185
15.1M
    }
186
15.1M
    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.1M
    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.1M
    return LZO_E_OK;
219
15.1M
}
lzo1z_9x.c:find_match
Line
Count
Source
149
13.2M
{
150
13.2M
    assert(c->init);
151
152
13.2M
    if (skip > 0)
153
771k
    {
154
771k
        assert(this_len >= skip);
155
771k
        swd_accept(s, this_len - skip);
156
771k
        c->textsize += this_len - skip + 1;
157
771k
    }
158
12.5M
    else
159
12.5M
    {
160
12.5M
        assert(this_len <= 1);
161
12.5M
        c->textsize += this_len - skip;
162
12.5M
    }
163
164
13.2M
    s->m_len = SWD_THRESHOLD;
165
13.2M
    s->m_off = 0;
166
13.2M
#ifdef SWD_BEST_OFF
167
13.2M
    if (s->use_best_off)
168
13.2M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
13.2M
#endif
170
13.2M
    swd_findbest(s);
171
13.2M
    c->m_len = s->m_len;
172
13.2M
    c->m_off = s->m_off;
173
174
13.2M
    swd_getbyte(s);
175
176
13.2M
    if (s->b_char < 0)
177
1.32k
    {
178
1.32k
        c->look = 0;
179
1.32k
        c->m_len = 0;
180
1.32k
        swd_exit(s);
181
1.32k
    }
182
13.2M
    else
183
13.2M
    {
184
13.2M
        c->look = s->look + 1;
185
13.2M
    }
186
13.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
13.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
13.2M
    return LZO_E_OK;
219
13.2M
}
lzo2a_9x.c:find_match
Line
Count
Source
149
3.47M
{
150
3.47M
    assert(c->init);
151
152
3.47M
    if (skip > 0)
153
149k
    {
154
149k
        assert(this_len >= skip);
155
149k
        swd_accept(s, this_len - skip);
156
149k
        c->textsize += this_len - skip + 1;
157
149k
    }
158
3.32M
    else
159
3.32M
    {
160
3.32M
        assert(this_len <= 1);
161
3.32M
        c->textsize += this_len - skip;
162
3.32M
    }
163
164
3.47M
    s->m_len = SWD_THRESHOLD;
165
3.47M
    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
3.47M
    swd_findbest(s);
171
3.47M
    c->m_len = s->m_len;
172
3.47M
    c->m_off = s->m_off;
173
174
3.47M
    swd_getbyte(s);
175
176
3.47M
    if (s->b_char < 0)
177
646
    {
178
646
        c->look = 0;
179
646
        c->m_len = 0;
180
646
        swd_exit(s);
181
646
    }
182
3.47M
    else
183
3.47M
    {
184
3.47M
        c->look = s->look + 1;
185
3.47M
    }
186
3.47M
    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
3.47M
    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
3.47M
    return LZO_E_OK;
219
3.47M
}
220
221
222
/* vim:set ts=4 sw=4 et: */