summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Kristian Rosbach <hk-git@circlestorm.org>2025-11-28 18:49:37 -0500
committerHans Kristian Rosbach <hk-github@circlestorm.org>2025-11-29 23:14:49 +0100
commit829a23473ca0943e2ebae582b1d2211b42d862f8 (patch)
tree859178fa4db6a7188e5bdd213d2ce8be30233de3
parent68c83bf42055a4313c16ae1073dd50cd72bbfb69 (diff)
downloadProject-Tick-829a23473ca0943e2ebae582b1d2211b42d862f8.tar.gz
Project-Tick-829a23473ca0943e2ebae582b1d2211b42d862f8.zip
Minor cleanups of some variables in deflate functions
-rw-r--r--deflate.h2
-rw-r--r--deflate_fast.c7
-rw-r--r--deflate_quick.c15
-rw-r--r--deflate_slow.c9
4 files changed, 12 insertions, 21 deletions
diff --git a/deflate.h b/deflate.h
index 26553983b2..6d5558d66c 100644
--- a/deflate.h
+++ b/deflate.h
@@ -155,7 +155,7 @@ struct ALIGNED_(64) internal_state {
int last_flush; /* value of flush param for previous deflate call */
int reproducible; /* Whether reproducible compression results are required. */
- int block_open;
+ unsigned int block_open;
/* Whether or not a block is currently open for the QUICK deflation scheme.
* This is set to 1 if there is an active block, or 0 if the block was just closed.
*/
diff --git a/deflate_fast.c b/deflate_fast.c
index e682697d5c..efb95b856e 100644
--- a/deflate_fast.c
+++ b/deflate_fast.c
@@ -17,9 +17,7 @@
* matches. It is used only for the fast compression options.
*/
Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
- Pos hash_head; /* head of the hash chain */
int bflush = 0; /* set if current block must be flushed */
- int64_t dist;
uint32_t match_len = 0;
for (;;) {
@@ -41,8 +39,8 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
* dictionary, and set hash_head to the head of the hash chain:
*/
if (s->lookahead >= WANT_MIN_MATCH) {
- hash_head = quick_insert_string(s, s->strstart);
- dist = (int64_t)s->strstart - hash_head;
+ Pos hash_head = quick_insert_string(s, s->strstart);
+ int64_t dist = (int64_t)s->strstart - hash_head;
/* Find the longest match, discarding those <= prev_length.
* At this point we have always match length < WANT_MIN_MATCH
@@ -94,6 +92,7 @@ Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
FLUSH_BLOCK(s, 0);
}
s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
+
if (UNLIKELY(flush == Z_FINISH)) {
FLUSH_BLOCK(s, 1);
return finish_done;
diff --git a/deflate_quick.c b/deflate_quick.c
index d5fd986d7a..f9312a2eba 100644
--- a/deflate_quick.c
+++ b/deflate_quick.c
@@ -29,7 +29,7 @@ extern const ct_data static_dtree[D_CODES];
#define QUICK_START_BLOCK(s, last) { \
zng_tr_emit_tree(s, STATIC_TREES, last); \
- s->block_open = 1 + (int)last; \
+ s->block_open = 1 + last; \
s->block_start = (int)s->strstart; \
}
@@ -45,12 +45,7 @@ extern const ct_data static_dtree[D_CODES];
}
Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
- Pos hash_head;
- int64_t dist;
- unsigned match_len, last;
-
-
- last = (flush == Z_FINISH) ? 1 : 0;
+ unsigned last = (flush == Z_FINISH) ? 1 : 0;
if (UNLIKELY(last && s->block_open != 2)) {
/* Emit end of previous block */
QUICK_END_BLOCK(s, 0);
@@ -86,15 +81,15 @@ Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
}
if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
- hash_head = quick_insert_string(s, s->strstart);
- dist = (int64_t)s->strstart - hash_head;
+ Pos hash_head = quick_insert_string(s, s->strstart);
+ int64_t dist = (int64_t)s->strstart - hash_head;
if (dist <= MAX_DIST(s) && dist > 0) {
const uint8_t *str_start = s->window + s->strstart;
const uint8_t *match_start = s->window + hash_head;
if (zng_memcmp_2(str_start, match_start) == 0) {
- match_len = FUNCTABLE_CALL(compare256)(str_start+2, match_start+2) + 2;
+ uint32_t match_len = FUNCTABLE_CALL(compare256)(str_start+2, match_start+2) + 2;
if (match_len >= WANT_MIN_MATCH) {
if (UNLIKELY(match_len > s->lookahead))
diff --git a/deflate_slow.c b/deflate_slow.c
index 4165eea2af..e9d7fc76ce 100644
--- a/deflate_slow.c
+++ b/deflate_slow.c
@@ -15,10 +15,7 @@
* no better match at the next window position.
*/
Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
- Pos hash_head; /* head of hash chain */
int bflush; /* set if current block must be flushed */
- int64_t dist;
- uint32_t match_len;
match_func longest_match;
if (s->max_chain_length <= 1024)
@@ -45,7 +42,7 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
/* Insert the string window[strstart .. strstart+2] in the
* dictionary, and set hash_head to the head of the hash chain:
*/
- hash_head = 0;
+ Pos hash_head = 0;
if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
hash_head = s->quick_insert_string(s, s->strstart);
}
@@ -53,8 +50,8 @@ Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
/* Find the longest match, discarding those <= prev_length.
*/
s->prev_match = (Pos)s->match_start;
- match_len = STD_MIN_MATCH - 1;
- dist = (int64_t)s->strstart - hash_head;
+ uint32_t match_len = STD_MIN_MATCH - 1;
+ int64_t dist = (int64_t)s->strstart - hash_head;
if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match && hash_head != 0) {
/* To simplify the code, we prevent matches with the string