]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Don't update prev if old head is same as new. 72/head
authorMika Lindqvist <postmaster@raasu.org>
Sun, 19 Jun 2016 12:21:46 +0000 (15:21 +0300)
committerMika Lindqvist <postmaster@raasu.org>
Mon, 4 Jul 2016 13:24:35 +0000 (16:24 +0300)
arch/x86/insert_string_sse.c
deflate_p.h

index 90c619a86f61eccadc553f05f790be984ebb4326..6d4ddaea519ef095afa8d176a6a8129780c6a8db 100644 (file)
@@ -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
index 9b45b091468cf8aa2197c4485f831537390975bf..4b8282d46bcb35a71256ea81d1507dee8f7dc072 100644 (file)
@@ -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;
 }