From: Mika Lindqvist Date: Sun, 19 Jun 2016 12:21:46 +0000 (+0300) Subject: Don't update prev if old head is same as new. X-Git-Tag: 1.9.9-b1~770^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F72%2Fhead;p=thirdparty%2Fzlib-ng.git Don't update prev if old head is same as new. --- diff --git a/arch/x86/insert_string_sse.c b/arch/x86/insert_string_sse.c index 90c619a8..6d4ddaea 100644 --- a/arch/x86/insert_string_sse.c +++ b/arch/x86/insert_string_sse.c @@ -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 diff --git a/deflate_p.h b/deflate_p.h index 9b45b091..4b8282d4 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -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; }