Coverage Report

Created: 2025-08-26 06:41

/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
132M
#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
548
{
117
548
    int r;
118
119
548
    assert(!c->init);
120
548
    c->init = 1;
121
122
548
    s->c = c;
123
124
548
    c->last_m_len = c->last_m_off = 0;
125
126
548
    c->textsize = c->codesize = c->printcount = 0;
127
548
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
548
    c->lazy = 0;
129
130
548
    r = swd_init(s,dict,dict_len);
131
548
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
548
    s->use_best_off = (flags & 1) ? 1 : 0;
138
548
    return LZO_E_OK;
139
548
}
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
691
{
117
691
    int r;
118
119
691
    assert(!c->init);
120
691
    c->init = 1;
121
122
691
    s->c = c;
123
124
691
    c->last_m_len = c->last_m_off = 0;
125
126
691
    c->textsize = c->codesize = c->printcount = 0;
127
691
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
691
    c->lazy = 0;
129
130
691
    r = swd_init(s,dict,dict_len);
131
691
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
691
    s->use_best_off = (flags & 1) ? 1 : 0;
138
691
    return LZO_E_OK;
139
691
}
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
680
{
117
680
    int r;
118
119
680
    assert(!c->init);
120
680
    c->init = 1;
121
122
680
    s->c = c;
123
124
680
    c->last_m_len = c->last_m_off = 0;
125
126
680
    c->textsize = c->codesize = c->printcount = 0;
127
680
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
680
    c->lazy = 0;
129
130
680
    r = swd_init(s,dict,dict_len);
131
680
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
680
    s->use_best_off = (flags & 1) ? 1 : 0;
138
680
    return LZO_E_OK;
139
680
}
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
47.1M
{
150
47.1M
    assert(c->init);
151
152
47.1M
    if (skip > 0)
153
2.51M
    {
154
2.51M
        assert(this_len >= skip);
155
2.51M
        swd_accept(s, this_len - skip);
156
2.51M
        c->textsize += this_len - skip + 1;
157
2.51M
    }
158
44.5M
    else
159
44.5M
    {
160
44.5M
        assert(this_len <= 1);
161
44.5M
        c->textsize += this_len - skip;
162
44.5M
    }
163
164
47.1M
    s->m_len = SWD_THRESHOLD;
165
47.1M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
32.4M
    if (s->use_best_off)
168
32.4M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
47.1M
    swd_findbest(s);
171
47.1M
    c->m_len = s->m_len;
172
47.1M
    c->m_off = s->m_off;
173
174
47.1M
    swd_getbyte(s);
175
176
47.1M
    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
47.1M
    else
183
47.1M
    {
184
47.1M
        c->look = s->look + 1;
185
47.1M
    }
186
47.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
47.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
47.1M
    return LZO_E_OK;
219
47.1M
}
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
548
    {
178
548
        c->look = 0;
179
548
        c->m_len = 0;
180
548
        swd_exit(s);
181
548
    }
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.91M
{
150
4.91M
    assert(c->init);
151
152
4.91M
    if (skip > 0)
153
182k
    {
154
182k
        assert(this_len >= skip);
155
182k
        swd_accept(s, this_len - skip);
156
182k
        c->textsize += this_len - skip + 1;
157
182k
    }
158
4.73M
    else
159
4.73M
    {
160
4.73M
        assert(this_len <= 1);
161
4.73M
        c->textsize += this_len - skip;
162
4.73M
    }
163
164
4.91M
    s->m_len = SWD_THRESHOLD;
165
4.91M
    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.91M
    swd_findbest(s);
171
4.91M
    c->m_len = s->m_len;
172
4.91M
    c->m_off = s->m_off;
173
174
4.91M
    swd_getbyte(s);
175
176
4.91M
    if (s->b_char < 0)
177
691
    {
178
691
        c->look = 0;
179
691
        c->m_len = 0;
180
691
        swd_exit(s);
181
691
    }
182
4.91M
    else
183
4.91M
    {
184
4.91M
        c->look = s->look + 1;
185
4.91M
    }
186
4.91M
    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.91M
    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.91M
    return LZO_E_OK;
219
4.91M
}
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
12.8M
{
150
12.8M
    assert(c->init);
151
152
12.8M
    if (skip > 0)
153
630k
    {
154
630k
        assert(this_len >= skip);
155
630k
        swd_accept(s, this_len - skip);
156
630k
        c->textsize += this_len - skip + 1;
157
630k
    }
158
12.2M
    else
159
12.2M
    {
160
12.2M
        assert(this_len <= 1);
161
12.2M
        c->textsize += this_len - skip;
162
12.2M
    }
163
164
12.8M
    s->m_len = SWD_THRESHOLD;
165
12.8M
    s->m_off = 0;
166
12.8M
#ifdef SWD_BEST_OFF
167
12.8M
    if (s->use_best_off)
168
12.8M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
12.8M
#endif
170
12.8M
    swd_findbest(s);
171
12.8M
    c->m_len = s->m_len;
172
12.8M
    c->m_off = s->m_off;
173
174
12.8M
    swd_getbyte(s);
175
176
12.8M
    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
12.8M
    else
183
12.8M
    {
184
12.8M
        c->look = s->look + 1;
185
12.8M
    }
186
12.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
12.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
12.8M
    return LZO_E_OK;
219
12.8M
}
lzo1z_9x.c:find_match
Line
Count
Source
149
11.9M
{
150
11.9M
    assert(c->init);
151
152
11.9M
    if (skip > 0)
153
695k
    {
154
695k
        assert(this_len >= skip);
155
695k
        swd_accept(s, this_len - skip);
156
695k
        c->textsize += this_len - skip + 1;
157
695k
    }
158
11.2M
    else
159
11.2M
    {
160
11.2M
        assert(this_len <= 1);
161
11.2M
        c->textsize += this_len - skip;
162
11.2M
    }
163
164
11.9M
    s->m_len = SWD_THRESHOLD;
165
11.9M
    s->m_off = 0;
166
11.9M
#ifdef SWD_BEST_OFF
167
11.9M
    if (s->use_best_off)
168
11.9M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
11.9M
#endif
170
11.9M
    swd_findbest(s);
171
11.9M
    c->m_len = s->m_len;
172
11.9M
    c->m_off = s->m_off;
173
174
11.9M
    swd_getbyte(s);
175
176
11.9M
    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
11.9M
    else
183
11.9M
    {
184
11.9M
        c->look = s->look + 1;
185
11.9M
    }
186
11.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
11.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
11.9M
    return LZO_E_OK;
219
11.9M
}
lzo2a_9x.c:find_match
Line
Count
Source
149
2.46M
{
150
2.46M
    assert(c->init);
151
152
2.46M
    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
2.31M
    else
159
2.31M
    {
160
2.31M
        assert(this_len <= 1);
161
2.31M
        c->textsize += this_len - skip;
162
2.31M
    }
163
164
2.46M
    s->m_len = SWD_THRESHOLD;
165
2.46M
    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
2.46M
    swd_findbest(s);
171
2.46M
    c->m_len = s->m_len;
172
2.46M
    c->m_off = s->m_off;
173
174
2.46M
    swd_getbyte(s);
175
176
2.46M
    if (s->b_char < 0)
177
680
    {
178
680
        c->look = 0;
179
680
        c->m_len = 0;
180
680
        swd_exit(s);
181
680
    }
182
2.46M
    else
183
2.46M
    {
184
2.46M
        c->look = s->look + 1;
185
2.46M
    }
186
2.46M
    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
2.46M
    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
2.46M
    return LZO_E_OK;
219
2.46M
}
220
221
222
/* vim:set ts=4 sw=4 et: */