unsigned int v, hv, i, k, p, wsiz;
if (mf->end - cur < bestlen + 1)
- return 0;
+ return -1;
v = get_unaligned((u16 *)cur);
hv = v ^ crc_ccitt_table[cur[2]];
return k - 1;
}
+static void kite_mf_hc3_skip(struct kite_matchfinder *mf)
+{
+ if (kite_mf_getmatches_hc3(mf, 0, 2) >= 0)
+ return;
+ mf->offset++;
+ /* mf->cyclic_pos = (mf->cyclic_pos + 1) & (mf->wsiz - 1); */
+}
+
/* let's align with zlib */
static const struct kite_matchfinder_cfg {
u16 good_length; /* reduce lazy search above this match length */
int matches = kite_mf_getmatches_hc3(mf, mf->depth,
kMatchMinLen - 1);
- if (matches) {
+ if (matches > 0) {
unsigned int len = mf->matches[matches].len;
unsigned int dist = mf->matches[matches].dist;
s->pos_in += len;
/* skip the rest bytes */
while (--len)
- (void)kite_mf_getmatches_hc3(mf, 0, 0);
+ kite_mf_hc3_skip(mf);
} else {
nomatch:
mf->matches[0].dist = s->in[s->pos_in];
if (len0 < mf->max_lazy) {
matches = kite_mf_getmatches_hc3(mf, mf->depth >>
(len0 >= mf->good_len), len0);
- if (matches) {
+ if (matches > 0) {
len = mf->matches[matches].len;
if (len == kMatchMinLen &&
mf->matches[matches].dist > ZLIB_DISTANCE_TOO_FAR) {
matches = 0;
len = kMatchMinLen - 1;
}
+ } else {
+ matches = 0;
}
} else {
matches = 0;
- (void)kite_mf_getmatches_hc3(mf, 0, 0);
+ kite_mf_hc3_skip(mf);
}
if (len < len0) {
s->pos_in += --len0;
/* skip the rest bytes */
while (--len0)
- (void)kite_mf_getmatches_hc3(mf, 0, 0);
+ kite_mf_hc3_skip(mf);
s->prev_valid = false;
s->prev_longest = 0;
} else {