);
#endif
- ret = s->prev[(str+idx) & s->w_mask] = s->head[h & s->hash_mask];
- s->head[h & s->hash_mask] = str+idx;
+ if (s->head[h & s->hash_mask] != str+idx) {
+ s->prev[(str+idx) & s->w_mask] = s->head[h & s->hash_mask];
+ s->head[h & s->hash_mask] = str+idx;
+ }
}
+ ret = s->prev[(str+count-1) & s->w_mask];
return ret;
}
#endif
for (idx = 0; idx < count; idx++) {
UPDATE_HASH(s, s->ins_h, str+idx);
- ret = s->prev[(str+idx) & s->w_mask] = s->head[s->ins_h];
- s->head[s->ins_h] = str+idx;
+ if (s->head[s->ins_h] != str+idx) {
+ s->prev[(str+idx) & s->w_mask] = s->head[s->ins_h];
+ s->head[s->ins_h] = str+idx;
+ }
}
+ ret = s->prev[(str+count-1) & s->w_mask];
return ret;
}