From: Hans Kristian Rosbach Date: Sat, 29 Aug 2020 11:48:23 +0000 (+0200) Subject: Minor comments/whitespace cleanup X-Git-Tag: 1.9.9-b1~57 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de160d6585250c368136ff642534deda6d8890a3;p=thirdparty%2Fzlib-ng.git Minor comments/whitespace cleanup --- diff --git a/deflate.h b/deflate.h index 633ce255..b42dc28d 100644 --- a/deflate.h +++ b/deflate.h @@ -176,15 +176,13 @@ typedef struct internal_state { */ unsigned int max_chain_length; - /* To speed up deflation, hash chains are never searched beyond this - * length. A higher limit improves compression ratio but degrades the - * speed. + /* To speed up deflation, hash chains are never searched beyond this length. + * A higher limit improves compression ratio but degrades the speed. */ unsigned int max_lazy_match; - /* Attempt to find a better match only when the current match is strictly - * smaller than this value. This mechanism is used only for compression - * levels >= 4. + /* Attempt to find a better match only when the current match is strictly smaller + * than this value. This mechanism is used only for compression levels >= 4. */ # define max_insert_length max_lazy_match /* Insert new strings in the hash table only if the match length is not @@ -263,13 +261,10 @@ typedef struct internal_state { #endif uint64_t bi_buf; - /* Output buffer. bits are inserted starting at the bottom (least - * significant bits). - */ + /* Output buffer. bits are inserted starting at the bottom (least significant bits). */ + int32_t bi_valid; - /* Number of valid bits in bi_buf. All bits above the last valid bit - * are always zero. - */ + /* Number of valid bits in bi_buf. All bits above the last valid bit are always zero. */ } deflate_state; diff --git a/match_tpl.h b/match_tpl.h index 12da39f4..823532cd 100644 --- a/match_tpl.h +++ b/match_tpl.h @@ -20,8 +20,7 @@ typedef uint8_t bestcmp_t; #endif -/* - * Set match_start to the longest match starting at the given string and +/* Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is garbage. * @@ -52,15 +51,12 @@ Z_INTERNAL int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { continue; \ return best_len; - /* - * The code is optimized for MAX_MATCH-2 multiple of 16. - */ + /* The code is optimized for MAX_MATCH-2 multiple of 16. */ Assert(MAX_MATCH == 258, "Code too clever"); best_len = s->prev_length ? s->prev_length : 1; - /* - * Calculate read offset which should only extend an extra byte + /* Calculate read offset which should only extend an extra byte * to find the next best match length. */ offset = best_len-1; @@ -82,16 +78,13 @@ Z_INTERNAL int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { #endif mbase_end = (mbase_start+offset); - /* - * Do not waste too much time if we already have a good match - */ + /* Do not waste too much time if we already have a good match */ chain_length = s->max_chain_length; if (best_len >= s->good_match) chain_length >>= 2; nice_match = (uint32_t)s->nice_match; - /* - * Stop when cur_match becomes <= limit. To simplify the code, + /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0 */ limit = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0; @@ -102,15 +95,12 @@ Z_INTERNAL int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { if (cur_match >= strstart) break; - /* - * Skip to next match if the match length cannot increase - * or if the match length is less than 2. Note that the checks - * below for insufficient lookahead only occur occasionally - * for performance reasons. Therefore uninitialized memory - * will be accessed and conditional jumps will be made that - * depend on those values. However the length of the match - * is limited to the lookahead, so the output of deflate is not - * affected by the uninitialized values. + /* Skip to next match if the match length cannot increase or if the match length is + * less than 2. Note that the checks below for insufficient lookahead only occur + * occasionally for performance reasons. + * Therefore uninitialized memory will be accessed and conditional jumps will be made + * that depend on those values. However the length of the match is limited to the + * lookahead, so the output of deflate is not affected by the uninitialized values. */ #ifdef UNALIGNED_OK if (best_len < sizeof(uint32_t)) { @@ -173,10 +163,8 @@ Z_INTERNAL int32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { #endif mbase_end = (mbase_start+offset); } else { - /* - * The probability of finding a match later if we here - * is pretty low, so for performance it's best to - * outright stop here for the lower compression levels + /* The probability of finding a match later if we here is pretty low, so for + * performance it's best to outright stop here for the lower compression levels */ if (s->level < EARLY_EXIT_TRIGGER_LEVEL) break; diff --git a/trees.c b/trees.c index 6a4362b0..2d1cccbb 100644 --- a/trees.c +++ b/trees.c @@ -333,7 +333,8 @@ static void build_tree(deflate_state *s, tree_desc *desc) { * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n+1]. * heap[0] is not used. */ - s->heap_len = 0, s->heap_max = HEAP_SIZE; + s->heap_len = 0; + s->heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].Freq != 0) {