]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Move zero check for insert_string count to fill_window since it is the only place...
authorNathan Moinvaziri <nathan@nathanm.com>
Wed, 19 Aug 2020 00:45:48 +0000 (17:45 -0700)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 20 Aug 2020 19:49:17 +0000 (21:49 +0200)
deflate.c
insert_string_tpl.h

index 014f56c8a655a1dddcf293b054954c06b998e680..1cc7642bf07c363abc7f1ed2a32e3f3f27af7561 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -1316,8 +1316,10 @@ void ZLIB_INTERNAL fill_window(deflate_state *s) {
             } else {
                 count = s->insert;
             }
-            functable.insert_string(s, str, count);
-            s->insert -= count;
+            if (count > 0) {
+                functable.insert_string(s, str, count);
+                s->insert -= count;
+            }
 #endif
         }
         /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
index 127a7ca8d1da03ce35eb0bd0dfed1dfd2868fcd4..4900010cac68cc9542c8012dcd813ef67ce1b15f 100644 (file)
@@ -61,17 +61,11 @@ ZLIB_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, const uint32_t str
  *    (except for the last MIN_MATCH-1 bytes of the input file).
  */
 ZLIB_INTERNAL Pos INSERT_STRING(deflate_state *const s, const uint32_t str, uint32_t count) {
-    Pos idx, ret;
-    uint8_t *strstart, *strend;
-
-    if (UNLIKELY(count == 0)) {
-        return s->prev[str & s->w_mask];
-    }
-
-    strstart = s->window + str;
-    strend = strstart + count - 1; /* last position */
+    Pos idx, ret = 0;
+    uint8_t *strstart = s->window + str;
+    uint8_t *strend = strstart + count - 1; /* last position */
 
-    for (ret = 0, idx = str; strstart <= strend; idx++, strstart++) {
+    for (idx = str; strstart <= strend; idx++, strstart++) {
         uint32_t val, hm, h = 0;
 
 #ifdef UNALIGNED_OK