Coverage Report

Created: 2025-07-18 06:09

/src/lzo-2.10/src/lzo_mchw.ch
Line
Count
Source (jump to first uncovered line)
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
125M
#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
6.32k
{
117
6.32k
    int r;
118
119
6.32k
    assert(!c->init);
120
6.32k
    c->init = 1;
121
122
6.32k
    s->c = c;
123
124
6.32k
    c->last_m_len = c->last_m_off = 0;
125
126
6.32k
    c->textsize = c->codesize = c->printcount = 0;
127
6.32k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
6.32k
    c->lazy = 0;
129
130
6.32k
    r = swd_init(s,dict,dict_len);
131
6.32k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
6.32k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
6.32k
    return LZO_E_OK;
139
6.32k
}
lzo1b_9x.c:init_match
Line
Count
Source
116
547
{
117
547
    int r;
118
119
547
    assert(!c->init);
120
547
    c->init = 1;
121
122
547
    s->c = c;
123
124
547
    c->last_m_len = c->last_m_off = 0;
125
126
547
    c->textsize = c->codesize = c->printcount = 0;
127
547
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
547
    c->lazy = 0;
129
130
547
    r = swd_init(s,dict,dict_len);
131
547
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
547
    s->use_best_off = (flags & 1) ? 1 : 0;
138
547
    return LZO_E_OK;
139
547
}
lzo1c_9x.c:init_match
Line
Count
Source
116
628
{
117
628
    int r;
118
119
628
    assert(!c->init);
120
628
    c->init = 1;
121
122
628
    s->c = c;
123
124
628
    c->last_m_len = c->last_m_off = 0;
125
126
628
    c->textsize = c->codesize = c->printcount = 0;
127
628
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
628
    c->lazy = 0;
129
130
628
    r = swd_init(s,dict,dict_len);
131
628
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
628
    s->use_best_off = (flags & 1) ? 1 : 0;
138
628
    return LZO_E_OK;
139
628
}
lzo1f_9x.c:init_match
Line
Count
Source
116
690
{
117
690
    int r;
118
119
690
    assert(!c->init);
120
690
    c->init = 1;
121
122
690
    s->c = c;
123
124
690
    c->last_m_len = c->last_m_off = 0;
125
126
690
    c->textsize = c->codesize = c->printcount = 0;
127
690
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
690
    c->lazy = 0;
129
130
690
    r = swd_init(s,dict,dict_len);
131
690
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
690
    s->use_best_off = (flags & 1) ? 1 : 0;
138
690
    return LZO_E_OK;
139
690
}
lzo1x_9x.c:init_match
Line
Count
Source
116
1.15k
{
117
1.15k
    int r;
118
119
1.15k
    assert(!c->init);
120
1.15k
    c->init = 1;
121
122
1.15k
    s->c = c;
123
124
1.15k
    c->last_m_len = c->last_m_off = 0;
125
126
1.15k
    c->textsize = c->codesize = c->printcount = 0;
127
1.15k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.15k
    c->lazy = 0;
129
130
1.15k
    r = swd_init(s,dict,dict_len);
131
1.15k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.15k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.15k
    return LZO_E_OK;
139
1.15k
}
lzo1y_9x.c:init_match
Line
Count
Source
116
1.17k
{
117
1.17k
    int r;
118
119
1.17k
    assert(!c->init);
120
1.17k
    c->init = 1;
121
122
1.17k
    s->c = c;
123
124
1.17k
    c->last_m_len = c->last_m_off = 0;
125
126
1.17k
    c->textsize = c->codesize = c->printcount = 0;
127
1.17k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.17k
    c->lazy = 0;
129
130
1.17k
    r = swd_init(s,dict,dict_len);
131
1.17k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.17k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.17k
    return LZO_E_OK;
139
1.17k
}
lzo1z_9x.c:init_match
Line
Count
Source
116
1.45k
{
117
1.45k
    int r;
118
119
1.45k
    assert(!c->init);
120
1.45k
    c->init = 1;
121
122
1.45k
    s->c = c;
123
124
1.45k
    c->last_m_len = c->last_m_off = 0;
125
126
1.45k
    c->textsize = c->codesize = c->printcount = 0;
127
1.45k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.45k
    c->lazy = 0;
129
130
1.45k
    r = swd_init(s,dict,dict_len);
131
1.45k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.45k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.45k
    return LZO_E_OK;
139
1.45k
}
lzo2a_9x.c:init_match
Line
Count
Source
116
679
{
117
679
    int r;
118
119
679
    assert(!c->init);
120
679
    c->init = 1;
121
122
679
    s->c = c;
123
124
679
    c->last_m_len = c->last_m_off = 0;
125
126
679
    c->textsize = c->codesize = c->printcount = 0;
127
679
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
679
    c->lazy = 0;
129
130
679
    r = swd_init(s,dict,dict_len);
131
679
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
679
    s->use_best_off = (flags & 1) ? 1 : 0;
138
679
    return LZO_E_OK;
139
679
}
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
42.9M
{
150
42.9M
    assert(c->init);
151
152
42.9M
    if (skip > 0)
153
2.54M
    {
154
2.54M
        assert(this_len >= skip);
155
2.54M
        swd_accept(s, this_len - skip);
156
2.54M
        c->textsize += this_len - skip + 1;
157
2.54M
    }
158
40.4M
    else
159
40.4M
    {
160
40.4M
        assert(this_len <= 1);
161
40.4M
        c->textsize += this_len - skip;
162
40.4M
    }
163
164
42.9M
    s->m_len = SWD_THRESHOLD;
165
42.9M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
29.3M
    if (s->use_best_off)
168
29.3M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
42.9M
    swd_findbest(s);
171
42.9M
    c->m_len = s->m_len;
172
42.9M
    c->m_off = s->m_off;
173
174
42.9M
    swd_getbyte(s);
175
176
42.9M
    if (s->b_char < 0)
177
6.32k
    {
178
6.32k
        c->look = 0;
179
6.32k
        c->m_len = 0;
180
6.32k
        swd_exit(s);
181
6.32k
    }
182
42.9M
    else
183
42.9M
    {
184
42.9M
        c->look = s->look + 1;
185
42.9M
    }
186
42.9M
    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
42.9M
    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
42.9M
    return LZO_E_OK;
219
42.9M
}
lzo1b_9x.c:find_match
Line
Count
Source
149
3.17M
{
150
3.17M
    assert(c->init);
151
152
3.17M
    if (skip > 0)
153
127k
    {
154
127k
        assert(this_len >= skip);
155
127k
        swd_accept(s, this_len - skip);
156
127k
        c->textsize += this_len - skip + 1;
157
127k
    }
158
3.04M
    else
159
3.04M
    {
160
3.04M
        assert(this_len <= 1);
161
3.04M
        c->textsize += this_len - skip;
162
3.04M
    }
163
164
3.17M
    s->m_len = SWD_THRESHOLD;
165
3.17M
    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.17M
    swd_findbest(s);
171
3.17M
    c->m_len = s->m_len;
172
3.17M
    c->m_off = s->m_off;
173
174
3.17M
    swd_getbyte(s);
175
176
3.17M
    if (s->b_char < 0)
177
547
    {
178
547
        c->look = 0;
179
547
        c->m_len = 0;
180
547
        swd_exit(s);
181
547
    }
182
3.17M
    else
183
3.17M
    {
184
3.17M
        c->look = s->look + 1;
185
3.17M
    }
186
3.17M
    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.17M
    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.17M
    return LZO_E_OK;
219
3.17M
}
lzo1c_9x.c:find_match
Line
Count
Source
149
4.08M
{
150
4.08M
    assert(c->init);
151
152
4.08M
    if (skip > 0)
153
158k
    {
154
158k
        assert(this_len >= skip);
155
158k
        swd_accept(s, this_len - skip);
156
158k
        c->textsize += this_len - skip + 1;
157
158k
    }
158
3.93M
    else
159
3.93M
    {
160
3.93M
        assert(this_len <= 1);
161
3.93M
        c->textsize += this_len - skip;
162
3.93M
    }
163
164
4.08M
    s->m_len = SWD_THRESHOLD;
165
4.08M
    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.08M
    swd_findbest(s);
171
4.08M
    c->m_len = s->m_len;
172
4.08M
    c->m_off = s->m_off;
173
174
4.08M
    swd_getbyte(s);
175
176
4.08M
    if (s->b_char < 0)
177
628
    {
178
628
        c->look = 0;
179
628
        c->m_len = 0;
180
628
        swd_exit(s);
181
628
    }
182
4.08M
    else
183
4.08M
    {
184
4.08M
        c->look = s->look + 1;
185
4.08M
    }
186
4.08M
    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.08M
    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.08M
    return LZO_E_OK;
219
4.08M
}
lzo1f_9x.c:find_match
Line
Count
Source
149
4.77M
{
150
4.77M
    assert(c->init);
151
152
4.77M
    if (skip > 0)
153
144k
    {
154
144k
        assert(this_len >= skip);
155
144k
        swd_accept(s, this_len - skip);
156
144k
        c->textsize += this_len - skip + 1;
157
144k
    }
158
4.63M
    else
159
4.63M
    {
160
4.63M
        assert(this_len <= 1);
161
4.63M
        c->textsize += this_len - skip;
162
4.63M
    }
163
164
4.77M
    s->m_len = SWD_THRESHOLD;
165
4.77M
    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.77M
    swd_findbest(s);
171
4.77M
    c->m_len = s->m_len;
172
4.77M
    c->m_off = s->m_off;
173
174
4.77M
    swd_getbyte(s);
175
176
4.77M
    if (s->b_char < 0)
177
690
    {
178
690
        c->look = 0;
179
690
        c->m_len = 0;
180
690
        swd_exit(s);
181
690
    }
182
4.77M
    else
183
4.77M
    {
184
4.77M
        c->look = s->look + 1;
185
4.77M
    }
186
4.77M
    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.77M
    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.77M
    return LZO_E_OK;
219
4.77M
}
lzo1x_9x.c:find_match
Line
Count
Source
149
7.61M
{
150
7.61M
    assert(c->init);
151
152
7.61M
    if (skip > 0)
153
574k
    {
154
574k
        assert(this_len >= skip);
155
574k
        swd_accept(s, this_len - skip);
156
574k
        c->textsize += this_len - skip + 1;
157
574k
    }
158
7.03M
    else
159
7.03M
    {
160
7.03M
        assert(this_len <= 1);
161
7.03M
        c->textsize += this_len - skip;
162
7.03M
    }
163
164
7.61M
    s->m_len = SWD_THRESHOLD;
165
7.61M
    s->m_off = 0;
166
7.61M
#ifdef SWD_BEST_OFF
167
7.61M
    if (s->use_best_off)
168
7.61M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
7.61M
#endif
170
7.61M
    swd_findbest(s);
171
7.61M
    c->m_len = s->m_len;
172
7.61M
    c->m_off = s->m_off;
173
174
7.61M
    swd_getbyte(s);
175
176
7.61M
    if (s->b_char < 0)
177
1.15k
    {
178
1.15k
        c->look = 0;
179
1.15k
        c->m_len = 0;
180
1.15k
        swd_exit(s);
181
1.15k
    }
182
7.60M
    else
183
7.60M
    {
184
7.60M
        c->look = s->look + 1;
185
7.60M
    }
186
7.61M
    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.61M
    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.61M
    return LZO_E_OK;
219
7.61M
}
lzo1y_9x.c:find_match
Line
Count
Source
149
11.7M
{
150
11.7M
    assert(c->init);
151
152
11.7M
    if (skip > 0)
153
609k
    {
154
609k
        assert(this_len >= skip);
155
609k
        swd_accept(s, this_len - skip);
156
609k
        c->textsize += this_len - skip + 1;
157
609k
    }
158
11.1M
    else
159
11.1M
    {
160
11.1M
        assert(this_len <= 1);
161
11.1M
        c->textsize += this_len - skip;
162
11.1M
    }
163
164
11.7M
    s->m_len = SWD_THRESHOLD;
165
11.7M
    s->m_off = 0;
166
11.7M
#ifdef SWD_BEST_OFF
167
11.7M
    if (s->use_best_off)
168
11.7M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
11.7M
#endif
170
11.7M
    swd_findbest(s);
171
11.7M
    c->m_len = s->m_len;
172
11.7M
    c->m_off = s->m_off;
173
174
11.7M
    swd_getbyte(s);
175
176
11.7M
    if (s->b_char < 0)
177
1.17k
    {
178
1.17k
        c->look = 0;
179
1.17k
        c->m_len = 0;
180
1.17k
        swd_exit(s);
181
1.17k
    }
182
11.7M
    else
183
11.7M
    {
184
11.7M
        c->look = s->look + 1;
185
11.7M
    }
186
11.7M
    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.7M
    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.7M
    return LZO_E_OK;
219
11.7M
}
lzo1z_9x.c:find_match
Line
Count
Source
149
9.98M
{
150
9.98M
    assert(c->init);
151
152
9.98M
    if (skip > 0)
153
809k
    {
154
809k
        assert(this_len >= skip);
155
809k
        swd_accept(s, this_len - skip);
156
809k
        c->textsize += this_len - skip + 1;
157
809k
    }
158
9.17M
    else
159
9.17M
    {
160
9.17M
        assert(this_len <= 1);
161
9.17M
        c->textsize += this_len - skip;
162
9.17M
    }
163
164
9.98M
    s->m_len = SWD_THRESHOLD;
165
9.98M
    s->m_off = 0;
166
9.98M
#ifdef SWD_BEST_OFF
167
9.98M
    if (s->use_best_off)
168
9.98M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
9.98M
#endif
170
9.98M
    swd_findbest(s);
171
9.98M
    c->m_len = s->m_len;
172
9.98M
    c->m_off = s->m_off;
173
174
9.98M
    swd_getbyte(s);
175
176
9.98M
    if (s->b_char < 0)
177
1.45k
    {
178
1.45k
        c->look = 0;
179
1.45k
        c->m_len = 0;
180
1.45k
        swd_exit(s);
181
1.45k
    }
182
9.98M
    else
183
9.98M
    {
184
9.98M
        c->look = s->look + 1;
185
9.98M
    }
186
9.98M
    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
9.98M
    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
9.98M
    return LZO_E_OK;
219
9.98M
}
lzo2a_9x.c:find_match
Line
Count
Source
149
1.57M
{
150
1.57M
    assert(c->init);
151
152
1.57M
    if (skip > 0)
153
124k
    {
154
124k
        assert(this_len >= skip);
155
124k
        swd_accept(s, this_len - skip);
156
124k
        c->textsize += this_len - skip + 1;
157
124k
    }
158
1.44M
    else
159
1.44M
    {
160
1.44M
        assert(this_len <= 1);
161
1.44M
        c->textsize += this_len - skip;
162
1.44M
    }
163
164
1.57M
    s->m_len = SWD_THRESHOLD;
165
1.57M
    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
1.57M
    swd_findbest(s);
171
1.57M
    c->m_len = s->m_len;
172
1.57M
    c->m_off = s->m_off;
173
174
1.57M
    swd_getbyte(s);
175
176
1.57M
    if (s->b_char < 0)
177
679
    {
178
679
        c->look = 0;
179
679
        c->m_len = 0;
180
679
        swd_exit(s);
181
679
    }
182
1.56M
    else
183
1.56M
    {
184
1.56M
        c->look = s->look + 1;
185
1.56M
    }
186
1.57M
    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
1.57M
    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
1.57M
    return LZO_E_OK;
219
1.57M
}
220
221
222
/* vim:set ts=4 sw=4 et: */