Coverage Report

Created: 2024-05-21 06:11

/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
163M
#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
8.36k
{
117
8.36k
    int r;
118
119
8.36k
    assert(!c->init);
120
8.36k
    c->init = 1;
121
122
8.36k
    s->c = c;
123
124
8.36k
    c->last_m_len = c->last_m_off = 0;
125
126
8.36k
    c->textsize = c->codesize = c->printcount = 0;
127
8.36k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
8.36k
    c->lazy = 0;
129
130
8.36k
    r = swd_init(s,dict,dict_len);
131
8.36k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
8.36k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
8.36k
    return LZO_E_OK;
139
8.36k
}
lzo1b_9x.c:init_match
Line
Count
Source
116
746
{
117
746
    int r;
118
119
746
    assert(!c->init);
120
746
    c->init = 1;
121
122
746
    s->c = c;
123
124
746
    c->last_m_len = c->last_m_off = 0;
125
126
746
    c->textsize = c->codesize = c->printcount = 0;
127
746
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
746
    c->lazy = 0;
129
130
746
    r = swd_init(s,dict,dict_len);
131
746
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
746
    s->use_best_off = (flags & 1) ? 1 : 0;
138
746
    return LZO_E_OK;
139
746
}
lzo1c_9x.c:init_match
Line
Count
Source
116
805
{
117
805
    int r;
118
119
805
    assert(!c->init);
120
805
    c->init = 1;
121
122
805
    s->c = c;
123
124
805
    c->last_m_len = c->last_m_off = 0;
125
126
805
    c->textsize = c->codesize = c->printcount = 0;
127
805
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
805
    c->lazy = 0;
129
130
805
    r = swd_init(s,dict,dict_len);
131
805
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
805
    s->use_best_off = (flags & 1) ? 1 : 0;
138
805
    return LZO_E_OK;
139
805
}
lzo1f_9x.c:init_match
Line
Count
Source
116
880
{
117
880
    int r;
118
119
880
    assert(!c->init);
120
880
    c->init = 1;
121
122
880
    s->c = c;
123
124
880
    c->last_m_len = c->last_m_off = 0;
125
126
880
    c->textsize = c->codesize = c->printcount = 0;
127
880
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
880
    c->lazy = 0;
129
130
880
    r = swd_init(s,dict,dict_len);
131
880
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
880
    s->use_best_off = (flags & 1) ? 1 : 0;
138
880
    return LZO_E_OK;
139
880
}
lzo1x_9x.c:init_match
Line
Count
Source
116
1.60k
{
117
1.60k
    int r;
118
119
1.60k
    assert(!c->init);
120
1.60k
    c->init = 1;
121
122
1.60k
    s->c = c;
123
124
1.60k
    c->last_m_len = c->last_m_off = 0;
125
126
1.60k
    c->textsize = c->codesize = c->printcount = 0;
127
1.60k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.60k
    c->lazy = 0;
129
130
1.60k
    r = swd_init(s,dict,dict_len);
131
1.60k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.60k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.60k
    return LZO_E_OK;
139
1.60k
}
lzo1y_9x.c:init_match
Line
Count
Source
116
1.60k
{
117
1.60k
    int r;
118
119
1.60k
    assert(!c->init);
120
1.60k
    c->init = 1;
121
122
1.60k
    s->c = c;
123
124
1.60k
    c->last_m_len = c->last_m_off = 0;
125
126
1.60k
    c->textsize = c->codesize = c->printcount = 0;
127
1.60k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.60k
    c->lazy = 0;
129
130
1.60k
    r = swd_init(s,dict,dict_len);
131
1.60k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.60k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.60k
    return LZO_E_OK;
139
1.60k
}
lzo1z_9x.c:init_match
Line
Count
Source
116
1.91k
{
117
1.91k
    int r;
118
119
1.91k
    assert(!c->init);
120
1.91k
    c->init = 1;
121
122
1.91k
    s->c = c;
123
124
1.91k
    c->last_m_len = c->last_m_off = 0;
125
126
1.91k
    c->textsize = c->codesize = c->printcount = 0;
127
1.91k
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
1.91k
    c->lazy = 0;
129
130
1.91k
    r = swd_init(s,dict,dict_len);
131
1.91k
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
1.91k
    s->use_best_off = (flags & 1) ? 1 : 0;
138
1.91k
    return LZO_E_OK;
139
1.91k
}
lzo2a_9x.c:init_match
Line
Count
Source
116
814
{
117
814
    int r;
118
119
814
    assert(!c->init);
120
814
    c->init = 1;
121
122
814
    s->c = c;
123
124
814
    c->last_m_len = c->last_m_off = 0;
125
126
814
    c->textsize = c->codesize = c->printcount = 0;
127
814
    c->lit_bytes = c->match_bytes = c->rep_bytes = 0;
128
814
    c->lazy = 0;
129
130
814
    r = swd_init(s,dict,dict_len);
131
814
    if (r != LZO_E_OK)
132
0
    {
133
0
        swd_exit(s);
134
0
        return r;
135
0
    }
136
137
814
    s->use_best_off = (flags & 1) ? 1 : 0;
138
814
    return LZO_E_OK;
139
814
}
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
83.4M
{
150
83.4M
    assert(c->init);
151
152
83.4M
    if (skip > 0)
153
3.25M
    {
154
3.25M
        assert(this_len >= skip);
155
3.25M
        swd_accept(s, this_len - skip);
156
3.25M
        c->textsize += this_len - skip + 1;
157
3.25M
    }
158
80.2M
    else
159
80.2M
    {
160
80.2M
        assert(this_len <= 1);
161
80.2M
        c->textsize += this_len - skip;
162
80.2M
    }
163
164
83.4M
    s->m_len = SWD_THRESHOLD;
165
83.4M
    s->m_off = 0;
166
#ifdef SWD_BEST_OFF
167
58.6M
    if (s->use_best_off)
168
58.6M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
#endif
170
83.4M
    swd_findbest(s);
171
83.4M
    c->m_len = s->m_len;
172
83.4M
    c->m_off = s->m_off;
173
174
83.4M
    swd_getbyte(s);
175
176
83.4M
    if (s->b_char < 0)
177
8.36k
    {
178
8.36k
        c->look = 0;
179
8.36k
        c->m_len = 0;
180
8.36k
        swd_exit(s);
181
8.36k
    }
182
83.4M
    else
183
83.4M
    {
184
83.4M
        c->look = s->look + 1;
185
83.4M
    }
186
83.4M
    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
83.4M
    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
83.4M
    return LZO_E_OK;
219
83.4M
}
lzo1b_9x.c:find_match
Line
Count
Source
149
3.98M
{
150
3.98M
    assert(c->init);
151
152
3.98M
    if (skip > 0)
153
176k
    {
154
176k
        assert(this_len >= skip);
155
176k
        swd_accept(s, this_len - skip);
156
176k
        c->textsize += this_len - skip + 1;
157
176k
    }
158
3.80M
    else
159
3.80M
    {
160
3.80M
        assert(this_len <= 1);
161
3.80M
        c->textsize += this_len - skip;
162
3.80M
    }
163
164
3.98M
    s->m_len = SWD_THRESHOLD;
165
3.98M
    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.98M
    swd_findbest(s);
171
3.98M
    c->m_len = s->m_len;
172
3.98M
    c->m_off = s->m_off;
173
174
3.98M
    swd_getbyte(s);
175
176
3.98M
    if (s->b_char < 0)
177
746
    {
178
746
        c->look = 0;
179
746
        c->m_len = 0;
180
746
        swd_exit(s);
181
746
    }
182
3.97M
    else
183
3.97M
    {
184
3.97M
        c->look = s->look + 1;
185
3.97M
    }
186
3.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
3.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
3.98M
    return LZO_E_OK;
219
3.98M
}
lzo1c_9x.c:find_match
Line
Count
Source
149
8.97M
{
150
8.97M
    assert(c->init);
151
152
8.97M
    if (skip > 0)
153
73.1k
    {
154
73.1k
        assert(this_len >= skip);
155
73.1k
        swd_accept(s, this_len - skip);
156
73.1k
        c->textsize += this_len - skip + 1;
157
73.1k
    }
158
8.90M
    else
159
8.90M
    {
160
8.90M
        assert(this_len <= 1);
161
8.90M
        c->textsize += this_len - skip;
162
8.90M
    }
163
164
8.97M
    s->m_len = SWD_THRESHOLD;
165
8.97M
    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
8.97M
    swd_findbest(s);
171
8.97M
    c->m_len = s->m_len;
172
8.97M
    c->m_off = s->m_off;
173
174
8.97M
    swd_getbyte(s);
175
176
8.97M
    if (s->b_char < 0)
177
805
    {
178
805
        c->look = 0;
179
805
        c->m_len = 0;
180
805
        swd_exit(s);
181
805
    }
182
8.97M
    else
183
8.97M
    {
184
8.97M
        c->look = s->look + 1;
185
8.97M
    }
186
8.97M
    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.97M
    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.97M
    return LZO_E_OK;
219
8.97M
}
lzo1f_9x.c:find_match
Line
Count
Source
149
6.24M
{
150
6.24M
    assert(c->init);
151
152
6.24M
    if (skip > 0)
153
138k
    {
154
138k
        assert(this_len >= skip);
155
138k
        swd_accept(s, this_len - skip);
156
138k
        c->textsize += this_len - skip + 1;
157
138k
    }
158
6.10M
    else
159
6.10M
    {
160
6.10M
        assert(this_len <= 1);
161
6.10M
        c->textsize += this_len - skip;
162
6.10M
    }
163
164
6.24M
    s->m_len = SWD_THRESHOLD;
165
6.24M
    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.24M
    swd_findbest(s);
171
6.24M
    c->m_len = s->m_len;
172
6.24M
    c->m_off = s->m_off;
173
174
6.24M
    swd_getbyte(s);
175
176
6.24M
    if (s->b_char < 0)
177
880
    {
178
880
        c->look = 0;
179
880
        c->m_len = 0;
180
880
        swd_exit(s);
181
880
    }
182
6.23M
    else
183
6.23M
    {
184
6.23M
        c->look = s->look + 1;
185
6.23M
    }
186
6.24M
    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.24M
    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.24M
    return LZO_E_OK;
219
6.24M
}
lzo1x_9x.c:find_match
Line
Count
Source
149
20.0M
{
150
20.0M
    assert(c->init);
151
152
20.0M
    if (skip > 0)
153
777k
    {
154
777k
        assert(this_len >= skip);
155
777k
        swd_accept(s, this_len - skip);
156
777k
        c->textsize += this_len - skip + 1;
157
777k
    }
158
19.2M
    else
159
19.2M
    {
160
19.2M
        assert(this_len <= 1);
161
19.2M
        c->textsize += this_len - skip;
162
19.2M
    }
163
164
20.0M
    s->m_len = SWD_THRESHOLD;
165
20.0M
    s->m_off = 0;
166
20.0M
#ifdef SWD_BEST_OFF
167
20.0M
    if (s->use_best_off)
168
20.0M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
20.0M
#endif
170
20.0M
    swd_findbest(s);
171
20.0M
    c->m_len = s->m_len;
172
20.0M
    c->m_off = s->m_off;
173
174
20.0M
    swd_getbyte(s);
175
176
20.0M
    if (s->b_char < 0)
177
1.60k
    {
178
1.60k
        c->look = 0;
179
1.60k
        c->m_len = 0;
180
1.60k
        swd_exit(s);
181
1.60k
    }
182
20.0M
    else
183
20.0M
    {
184
20.0M
        c->look = s->look + 1;
185
20.0M
    }
186
20.0M
    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
20.0M
    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
20.0M
    return LZO_E_OK;
219
20.0M
}
lzo1y_9x.c:find_match
Line
Count
Source
149
18.7M
{
150
18.7M
    assert(c->init);
151
152
18.7M
    if (skip > 0)
153
677k
    {
154
677k
        assert(this_len >= skip);
155
677k
        swd_accept(s, this_len - skip);
156
677k
        c->textsize += this_len - skip + 1;
157
677k
    }
158
18.0M
    else
159
18.0M
    {
160
18.0M
        assert(this_len <= 1);
161
18.0M
        c->textsize += this_len - skip;
162
18.0M
    }
163
164
18.7M
    s->m_len = SWD_THRESHOLD;
165
18.7M
    s->m_off = 0;
166
18.7M
#ifdef SWD_BEST_OFF
167
18.7M
    if (s->use_best_off)
168
18.7M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
18.7M
#endif
170
18.7M
    swd_findbest(s);
171
18.7M
    c->m_len = s->m_len;
172
18.7M
    c->m_off = s->m_off;
173
174
18.7M
    swd_getbyte(s);
175
176
18.7M
    if (s->b_char < 0)
177
1.60k
    {
178
1.60k
        c->look = 0;
179
1.60k
        c->m_len = 0;
180
1.60k
        swd_exit(s);
181
1.60k
    }
182
18.7M
    else
183
18.7M
    {
184
18.7M
        c->look = s->look + 1;
185
18.7M
    }
186
18.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
18.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
18.7M
    return LZO_E_OK;
219
18.7M
}
lzo1z_9x.c:find_match
Line
Count
Source
149
19.8M
{
150
19.8M
    assert(c->init);
151
152
19.8M
    if (skip > 0)
153
967k
    {
154
967k
        assert(this_len >= skip);
155
967k
        swd_accept(s, this_len - skip);
156
967k
        c->textsize += this_len - skip + 1;
157
967k
    }
158
18.8M
    else
159
18.8M
    {
160
18.8M
        assert(this_len <= 1);
161
18.8M
        c->textsize += this_len - skip;
162
18.8M
    }
163
164
19.8M
    s->m_len = SWD_THRESHOLD;
165
19.8M
    s->m_off = 0;
166
19.8M
#ifdef SWD_BEST_OFF
167
19.8M
    if (s->use_best_off)
168
19.8M
        lzo_memset(s->best_pos,0,sizeof(s->best_pos));
169
19.8M
#endif
170
19.8M
    swd_findbest(s);
171
19.8M
    c->m_len = s->m_len;
172
19.8M
    c->m_off = s->m_off;
173
174
19.8M
    swd_getbyte(s);
175
176
19.8M
    if (s->b_char < 0)
177
1.91k
    {
178
1.91k
        c->look = 0;
179
1.91k
        c->m_len = 0;
180
1.91k
        swd_exit(s);
181
1.91k
    }
182
19.8M
    else
183
19.8M
    {
184
19.8M
        c->look = s->look + 1;
185
19.8M
    }
186
19.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
19.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
19.8M
    return LZO_E_OK;
219
19.8M
}
lzo2a_9x.c:find_match
Line
Count
Source
149
5.64M
{
150
5.64M
    assert(c->init);
151
152
5.64M
    if (skip > 0)
153
446k
    {
154
446k
        assert(this_len >= skip);
155
446k
        swd_accept(s, this_len - skip);
156
446k
        c->textsize += this_len - skip + 1;
157
446k
    }
158
5.19M
    else
159
5.19M
    {
160
5.19M
        assert(this_len <= 1);
161
5.19M
        c->textsize += this_len - skip;
162
5.19M
    }
163
164
5.64M
    s->m_len = SWD_THRESHOLD;
165
5.64M
    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.64M
    swd_findbest(s);
171
5.64M
    c->m_len = s->m_len;
172
5.64M
    c->m_off = s->m_off;
173
174
5.64M
    swd_getbyte(s);
175
176
5.64M
    if (s->b_char < 0)
177
814
    {
178
814
        c->look = 0;
179
814
        c->m_len = 0;
180
814
        swd_exit(s);
181
814
    }
182
5.64M
    else
183
5.64M
    {
184
5.64M
        c->look = s->look + 1;
185
5.64M
    }
186
5.64M
    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.64M
    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.64M
    return LZO_E_OK;
219
5.64M
}
220
221
222
/* vim:set ts=4 sw=4 et: */