[git commit] gzip: code shrink

Denys Vlasenko vda.linux at googlemail.com
Thu Sep 5 11:26:58 UTC 2019


commit: https://git.busybox.net/busybox/commit/?id=750137ef7ce3d21511b4638d25a4fce0a811b60a
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
gzip_main                                            267     264      -3

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 archival/gzip.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/archival/gzip.c b/archival/gzip.c
index b08e60efd..3966a06b4 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -259,7 +259,7 @@ enum {
 
 #if !ENABLE_FEATURE_GZIP_LEVELS
 
-	comp_level = 6,
+	comp_level_minus4 = 6 - 4,
 	max_chain_length = 128,
 /* To speed up deflation, hash chains are never searched beyond this length.
  * A higher limit improves compression ratio but degrades the speed.
@@ -335,16 +335,16 @@ struct globals {
 #define head (G1.prev + WSIZE) /* hash head (see deflate.c) */
 
 #if ENABLE_FEATURE_GZIP_LEVELS
-	unsigned comp_level;
+	unsigned comp_level_minus4;	/* can be a byte */
 	unsigned max_chain_length;
 	unsigned max_lazy_match;
 	unsigned good_match;
 	unsigned nice_match;
-#define comp_level       (G1.comp_level)
-#define max_chain_length (G1.max_chain_length)
-#define max_lazy_match   (G1.max_lazy_match)
-#define good_match       (G1.good_match)
-#define nice_match       (G1.nice_match)
+#define comp_level_minus4 (G1.comp_level_minus4)
+#define max_chain_length  (G1.max_chain_length)
+#define max_lazy_match    (G1.max_lazy_match)
+#define good_match        (G1.good_match)
+#define nice_match        (G1.nice_match)
 #endif
 
 /* =========================================================================== */
@@ -2082,7 +2082,7 @@ static void zip(void)
 	deflate_flags = 0x300; /* extra flags. OS id = 3 (Unix) */
 #if ENABLE_FEATURE_GZIP_LEVELS
 	/* Note that comp_level < 4 do not exist in this version of gzip */
-	if (comp_level == 9) {
+	if (comp_level_minus4 == 9 - 4) {
 		deflate_flags |= 0x02; /* SLOW flag */
 	}
 #endif
@@ -2232,7 +2232,7 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
 		opt = 1 << 5; /* default: 6 */
 	opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */
 
-	comp_level = opt + 4;
+	comp_level_minus4 = opt;
 
 	max_chain_length = 1 << gzip_level_config[opt].chain_shift;
 	good_match	 = gzip_level_config[opt].good;


More information about the busybox-cvs mailing list