]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Let fill_window_c() and fill_window_sse() use insert_string().
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 17 Mar 2017 11:17:20 +0000 (12:17 +0100)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 24 Mar 2017 21:01:48 +0000 (22:01 +0100)
And let the code assume MIN_MATCH is 3, so a bulk insert can be used.

arch/x86/fill_window_sse.c
deflate.c

index d82b1d1bcb8daea1a1483085175b85ce81cec504..c71059056e2dae1988d22883e0a658ce534c279f 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <immintrin.h>
 #include "deflate.h"
+#include "deflate_p.h"
 
 extern int read_buf(z_stream *strm, unsigned char *buf, unsigned size);
 
@@ -108,19 +109,26 @@ ZLIB_INTERNAL void fill_window_sse(deflate_state *s) {
             unsigned int str = s->strstart - s->insert;
             s->ins_h = s->window[str];
             if (str >= 1)
-                UPDATE_HASH(s, s->ins_h, str + 1 - (MIN_MATCH-1));
+                insert_string(s, str + 2 - MIN_MATCH, 1);
 #if MIN_MATCH != 3
-            Call UPDATE_HASH() MIN_MATCH-3 more times
-#endif
+#error Call insert_string() MIN_MATCH-3 more times
             while (s->insert) {
-                UPDATE_HASH(s, s->ins_h, str);
-                s->prev[str & s->w_mask] = s->head[s->ins_h];
-                s->head[s->ins_h] = (Pos)str;
+                insert_string(s, str, 1);
                 str++;
                 s->insert--;
                 if (s->lookahead + s->insert < MIN_MATCH)
                     break;
             }
+#else
+            unsigned int count;
+            if (unlikely(s->lookahead == 1)){
+                count = s->insert - 1;
+            }else{
+                count = s->insert;
+            }
+            insert_string(s,str,count);
+            s->insert -= count;
+#endif
         }
         /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
          * but this is not important since only literal bytes will be emitted.
index 710f19faa822e645c307c3eab3bfe41b2061ed98..78273e54b2541920359cac75d3872c592e4e1f78 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -1256,8 +1256,7 @@ void fill_window_c(deflate_state *s) {
             if (str >= 1)
                 insert_string(s, str + 2 - MIN_MATCH, 1);
 #if MIN_MATCH != 3
-#warning    Call insert_string() MIN_MATCH-3 more times
-#endif
+#error Call insert_string() MIN_MATCH-3 more times
             while (s->insert) {
                 insert_string(s, str, 1);
                 str++;
@@ -1265,6 +1264,16 @@ void fill_window_c(deflate_state *s) {
                 if (s->lookahead + s->insert < MIN_MATCH)
                     break;
             }
+#else
+            unsigned int count;
+            if (unlikely(s->lookahead == 1)){
+                count = s->insert - 1;
+            }else{
+                count = s->insert;
+            }
+            insert_string(s,str,count);
+            s->insert -= count;
+#endif
         }
         /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage,
          * but this is not important since only literal bytes will be emitted.