]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Merge insert_string and bulk_insert_str.
authorMika Lindqvist <postmaster@raasu.org>
Sun, 27 Mar 2016 12:02:54 +0000 (15:02 +0300)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Mon, 30 Jan 2017 11:07:06 +0000 (12:07 +0100)
** Partial merge of this commit, based on a8c94e9f5a3b9d3c62182bcf84e72304a3c1a6e5
Excludes changes to fill_window_sse.c, changes to fill_window_c() in deflate.c
and several unrelated changes in the commit.

deflate.c
deflate_fast.c
deflate_medium.c
deflate_p.h
deflate_slow.c

index 556ebaf719a6933c863a770088b9823c25da43df..0b392a1e5612631edc078fc1660e023cce3a783a 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -312,7 +312,7 @@ int ZEXPORT deflateSetDictionary(z_stream *strm, const unsigned char *dictionary
     while (s->lookahead >= MIN_MATCH) {
         str = s->strstart;
         n = s->lookahead - (MIN_MATCH-1);
-        bulk_insert_str(s, str, n);
+        insert_string(s, str, n);
         s->strstart = str + n;
         s->lookahead = MIN_MATCH-1;
         fill_window(s);
index 59618a37fdb19ff06bf141432d5237a8678fd457..c169053758de0af37e9f403c195e3863a3110da0 100644 (file)
@@ -39,7 +39,7 @@ block_state deflate_fast(deflate_state *s, int flush) {
          */
         hash_head = NIL;
         if (s->lookahead >= MIN_MATCH) {
-            hash_head = insert_string(s, s->strstart);
+            hash_head = insert_string(s, s->strstart, 1);
         }
 
         /* Find the longest match, discarding those <= prev_length.
@@ -68,7 +68,7 @@ block_state deflate_fast(deflate_state *s, int flush) {
                 s->strstart++;
 #ifdef NOT_TWEAK_COMPILER
                 do {
-                    insert_string(s, s->strstart);
+                    insert_string(s, s->strstart, 1);
                     s->strstart++;
                     /* strstart never exceeds WSIZE-MAX_MATCH, so there are
                      * always MIN_MATCH bytes ahead.
@@ -76,7 +76,7 @@ block_state deflate_fast(deflate_state *s, int flush) {
                 } while (--s->match_length != 0);
 #else
                 {
-                    bulk_insert_str(s, s->strstart, s->match_length);
+                    insert_string(s, s->strstart, s->match_length);
                     s->strstart += s->match_length;
                     s->match_length = 0;
                 }
@@ -86,9 +86,9 @@ block_state deflate_fast(deflate_state *s, int flush) {
                 s->match_length = 0;
                 s->ins_h = s->window[s->strstart];
 #ifndef NOT_TWEAK_COMPILER
-                bulk_insert_str(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2);
+                insert_string(s, s->strstart + 2 - MIN_MATCH, MIN_MATCH - 2);
 #else
-                insert_string(s, s->strstart + 2 - MIN_MATCH);
+                insert_string(s, s->strstart + 2 - MIN_MATCH, 1);
 #if MIN_MATCH != 3
 #warning        Call insert_string() MIN_MATCH-3 more times
 #endif
index c5d39aa4457af0be700db71d580fb501e21c9275..26a12ebdaa54553a68ead7762ae78aa7cfccebbe 100644 (file)
@@ -63,7 +63,7 @@ static void insert_match(deflate_state *s, struct match match) {
 
             if (match.match_length) {
                 if (match.strstart >= match.orgstart) {
-                    insert_string(s, match.strstart);
+                    insert_string(s, match.strstart, 1);
                 }
             }
         }
@@ -93,7 +93,7 @@ static void insert_match(deflate_state *s, struct match match) {
 #ifdef NOT_TWEAK_COMPILER
         do {
             if (likely(match.strstart >= match.orgstart)) {
-                insert_string(s, match.strstart);
+                insert_string(s, match.strstart, 1);
             }
             match.strstart++;
             /* strstart never exceeds WSIZE-MAX_MATCH, so there are
@@ -113,9 +113,9 @@ static void insert_match(deflate_state *s, struct match match) {
         s->ins_h = s->window[match.strstart];
         if (match.strstart >= 1)
 #ifndef NOT_TWEAK_COMPILER
-            bulk_insert_str(s, match.strstart + 2 - MIN_MATCH, MIN_MATCH - 2);
+            insert_string(s, match.strstart + 2 - MIN_MATCH, MIN_MATCH - 2);
 #else
-            insert_string(s, match.strstart + 2 - MIN_MATCH);
+            insert_string(s, match.strstart + 2 - MIN_MATCH, 1);
 #if MIN_MATCH != 3
 #warning    Call insert_string() MIN_MATCH-3 more times
 #endif
@@ -233,7 +233,7 @@ block_state deflate_medium(deflate_state *s, int flush) {
         } else {
             hash_head = 0;
             if (s->lookahead >= MIN_MATCH) {
-                hash_head = insert_string(s, s->strstart);
+                hash_head = insert_string(s, s->strstart, 1);
             }
 
             /* set up the initial match to be a 1 byte literal */
@@ -267,7 +267,7 @@ block_state deflate_medium(deflate_state *s, int flush) {
         /* now, look ahead one */
         if (s->lookahead > MIN_LOOKAHEAD) {
             s->strstart = current_match.strstart + current_match.match_length;
-            hash_head = insert_string(s, s->strstart);
+            hash_head = insert_string(s, s->strstart, 1);
 
             /* set up the initial match to be a 1 byte literal */
             next_match.match_start = 0;
index d5e315cbd130608692ea5d693493f21bc59422b1..8965980551112f08a563a28f621b238a031f2b71 100644 (file)
@@ -51,27 +51,14 @@ static inline Pos insert_string_c(deflate_state *const s, const Pos str, uInt co
     return ret;
 }
 
-static inline Pos insert_string(deflate_state *const s, const Pos str) {
+static inline Pos insert_string(deflate_state *const s, const Pos str, uInt count) {
 #ifdef X86_SSE4_2_CRC_HASH
     if (x86_cpu_has_sse42)
-        return insert_string_sse(s, str, 1);
+        return insert_string_sse(s, str, count);
 #endif
-    return insert_string_c(s, str, 1);
+    return insert_string_c(s, str, count);
 }
 
-#ifndef NOT_TWEAK_COMPILER
-static inline void bulk_insert_str(deflate_state *const s, Pos startpos, uInt count) {
-# ifdef X86_SSE4_2_CRC_HASH
-    if (x86_cpu_has_sse42) {
-        insert_string_sse(s, startpos, count);
-    } else
-# endif
-    {
-        insert_string_c(s, startpos, count);
-    }
-}
-#endif /* NOT_TWEAK_COMPILER */
-
 /* ===========================================================================
  * Flush the current block, with given end-of-file flag.
  * IN assertion: strstart is set to the end of the current match.
index 6a855f0c837d69eb7630b751989a06dcd72ad8a4..f9e81d5ffdf32643c1b94f754548c1f81eae755a 100644 (file)
@@ -47,7 +47,7 @@ block_state deflate_slow(deflate_state *s, int flush) {
          */
         hash_head = NIL;
         if (s->lookahead >= MIN_MATCH) {
-            hash_head = insert_string(s, s->strstart);
+            hash_head = insert_string(s, s->strstart, 1);
         }
 
         /* Find the longest match, discarding those <= prev_length.
@@ -97,7 +97,7 @@ block_state deflate_slow(deflate_state *s, int flush) {
             s->prev_length -= 2;
             do {
                 if (++s->strstart <= max_insert) {
-                    insert_string(s, s->strstart);
+                    insert_string(s, s->strstart, 1);
                 }
             } while (--s->prev_length != 0);
             s->match_available = 0;
@@ -110,7 +110,7 @@ block_state deflate_slow(deflate_state *s, int flush) {
                 if (unlikely(insert_cnt > max_insert - s->strstart))
                     insert_cnt = max_insert - s->strstart;
 
-                bulk_insert_str(s, s->strstart + 1, insert_cnt);
+                insert_string(s, s->strstart + 1, insert_cnt);
                 s->prev_length = 0;
                 s->match_available = 0;
                 s->match_length = MIN_MATCH-1;