]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Clean up usage of bflush make more similar for each deflate strategy.
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Fri, 1 Nov 2019 10:39:46 +0000 (11:39 +0100)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Wed, 18 Mar 2020 10:04:05 +0000 (11:04 +0100)
deflate.c
deflate_fast.c
deflate_medium.c
deflate_slow.c

index 2309a80fe371633c7cf025edc10afbd05ef72c52..edc9d712352701ce8cfd461f5ecdfdd8debfc691 100644 (file)
--- a/deflate.c
+++ b/deflate.c
@@ -1552,7 +1552,7 @@ static block_state deflate_stored(deflate_state *s, int flush) {
  * deflate switches away from Z_RLE.)
  */
 static block_state deflate_rle(deflate_state *s, int flush) {
-    int bflush;                     /* set if current block must be flushed */
+    int bflush = 0;                 /* set if current block must be flushed */
     unsigned int prev;              /* byte at distance one to match */
     unsigned char *scan, *strend;   /* scan goes up to strend for length of run */
 
@@ -1624,7 +1624,7 @@ static block_state deflate_rle(deflate_state *s, int flush) {
  * (It will be regenerated if this run of deflate switches away from Huffman.)
  */
 static block_state deflate_huff(deflate_state *s, int flush) {
-    int bflush;             /* set if current block must be flushed */
+    int bflush = 0;         /* set if current block must be flushed */
 
     for (;;) {
         /* Make sure that we have a literal to write. */
index cbd5bde467f16a0b8e7b20fe32bc93ea5f69e42e..af1401169d2d2a921791f4b0ba4489b0b23883d5 100644 (file)
@@ -19,7 +19,7 @@
  */
 ZLIB_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
     IPos hash_head;       /* head of the hash chain */
-    int bflush;           /* set if current block must be flushed */
+    int bflush = 0;       /* set if current block must be flushed */
 
     for (;;) {
         /* Make sure that we always have enough lookahead, except
index 052a060cf97f8978725746cab46316578eae7446..ee988cc3ec7a9840f7b771737ab45ecb334cdfa4 100644 (file)
@@ -21,25 +21,25 @@ struct match {
 };
 
 static int emit_match(deflate_state *s, struct match match) {
-    int flush = 0;
+    int bflush = 0;
 
     /* matches that are not long enough we need to emit as literals */
     if (match.match_length < MIN_MATCH) {
         while (match.match_length) {
-            flush += zng_tr_tally_lit(s, s->window[match.strstart]);
+            bflush += zng_tr_tally_lit(s, s->window[match.strstart]);
             s->lookahead--;
             match.strstart++;
             match.match_length--;
         }
-        return flush;
+        return bflush;
     }
 
     check_match(s, match.strstart, match.match_start, match.match_length);
 
-    flush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH);
+    bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - MIN_MATCH);
 
     s->lookahead -= match.match_length;
-    return flush;
+    return bflush;
 }
 
 static void insert_match(deflate_state *s, struct match match) {
@@ -196,7 +196,7 @@ ZLIB_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
 
     for (;;) {
         IPos hash_head = 0;   /* head of the hash chain */
-        int bflush;           /* set if current block must be flushed */
+        int bflush = 0;       /* set if current block must be flushed */
 
         /* Make sure that we always have enough lookahead, except
          * at the end of the input file. We need MAX_MATCH bytes
index 11dedfb29905d98398f7347bd170f5f8e0bf811f..43931f227f133695fa2fb114b03d9f0779c5e54c 100644 (file)
@@ -26,7 +26,7 @@
  */
 ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
     IPos hash_head;          /* head of hash chain */
-    int bflush;              /* set if current block must be flushed */
+    int bflush = 0;          /* set if current block must be flushed */
 
     /* Process the input block. */
     for (;;) {
@@ -122,7 +122,8 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
             }
 #endif /*NOT_TWEAK_COMPILER*/
 
-            if (bflush) FLUSH_BLOCK(s, 0);
+            if (bflush)
+                FLUSH_BLOCK(s, 0);
 
         } else if (s->match_available) {
             /* If there was no match at the previous position, output a
@@ -131,9 +132,8 @@ ZLIB_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
              */
             Tracevv((stderr, "%c", s->window[s->strstart-1]));
             bflush = zng_tr_tally_lit(s, s->window[s->strstart-1]);
-            if (bflush) {
+            if (bflush)
                 FLUSH_BLOCK_ONLY(s, 0);
-            }
             s->strstart++;
             s->lookahead--;
             if (s->strm->avail_out == 0)