From 2f632a11a4f20dc4fa257f3df7276eda8dc7b178 Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Thu, 11 Dec 2025 20:34:05 +0100 Subject: Use uint32_t for hash_head in update_hash/insert_string --- insert_string_tpl.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'insert_string_tpl.h') diff --git a/insert_string_tpl.h b/insert_string_tpl.h index e507fb5917..8084054864 100644 --- a/insert_string_tpl.h +++ b/insert_string_tpl.h @@ -45,9 +45,8 @@ Z_FORCEINLINE static uint32_t UPDATE_HASH(uint32_t h, uint32_t val) { * to the previous head of the hash chain (the most recent string with same hash key). * Return the previous length of the hash chain. */ -Z_FORCEINLINE static Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) { - uint32_t hm; - Pos head; +Z_FORCEINLINE static uint32_t QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str, uint32_t val) { + uint32_t hm, head; HASH_CALC_VAR_INIT; HASH_CALC(HASH_CALC_VAR, val); @@ -56,7 +55,7 @@ Z_FORCEINLINE static Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str head = s->head[hm]; if (LIKELY(head != str)) { - s->prev[str & W_MASK(s)] = head; + s->prev[str & W_MASK(s)] = (Pos)head; s->head[hm] = (Pos)str; } return head; @@ -67,10 +66,9 @@ Z_FORCEINLINE static Pos QUICK_INSERT_VALUE(deflate_state *const s, uint32_t str * of the hash chain (the most recent string with same hash key). Return * the previous length of the hash chain. */ -Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) { +Z_FORCEINLINE static uint32_t QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) { uint8_t *strstart = s->window + str + HASH_CALC_OFFSET; - uint32_t val, hm; - Pos head; + uint32_t val, hm, head; HASH_CALC_VAR_INIT; HASH_CALC_READ; @@ -80,7 +78,7 @@ Z_FORCEINLINE static Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t st head = s->head[hm]; if (LIKELY(head != str)) { - s->prev[str & W_MASK(s)] = head; + s->prev[str & W_MASK(s)] = (Pos)head; s->head[hm] = (Pos)str; } return head; @@ -103,8 +101,8 @@ Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, ui Pos *prevp = s->prev; const unsigned int w_mask = W_MASK(s); - for (Pos idx = (Pos)str; strstart < strend; idx++, strstart++) { - uint32_t val, hm; + for (uint32_t idx = str; strstart < strend; idx++, strstart++) { + uint32_t val, hm, head; HASH_CALC_VAR_INIT; HASH_CALC_READ; @@ -112,10 +110,10 @@ Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, ui HASH_CALC_VAR &= HASH_CALC_MASK; hm = HASH_CALC_VAR; - Pos head = headp[hm]; + head = headp[hm]; if (LIKELY(head != idx)) { - prevp[idx & w_mask] = head; - headp[hm] = idx; + prevp[idx & w_mask] = (Pos)head; + headp[hm] = (Pos)idx; } } } -- cgit 0.0.5-2-1-g0f52