Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request madler#72 from mtl1979/duphead
Browse files Browse the repository at this point in the history
Don't update prev if old head is same as new.
  • Loading branch information
Dead2 authored Jul 7, 2016
2 parents ceffbfa + 2b9bf9e commit 515fcf5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 5 additions & 2 deletions arch/x86/insert_string_sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,12 @@ Pos insert_string_sse(deflate_state *const s, const Pos str, unsigned int count)
);
#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
7 changes: 5 additions & 2 deletions deflate_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ local inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt cou

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;
}

Expand Down

0 comments on commit 515fcf5

Please sign in to comment.