diff options
| -rw-r--r-- | deflate.c | 1 | ||||
| -rw-r--r-- | deflate.h | 4 | ||||
| -rw-r--r-- | insert_string_tpl.h | 6 | ||||
| -rw-r--r-- | match_tpl.h | 2 | ||||
| -rw-r--r-- | test/benchmarks/benchmark_insert_string.cc | 1 |
5 files changed, 7 insertions, 7 deletions
@@ -304,7 +304,6 @@ int32_t ZNG_CONDEXPORT PREFIX(deflateInit2)(PREFIX3(stream) *strm, int32_t level s->gzhead = NULL; s->w_bits = (unsigned int)windowBits; s->w_size = 1 << s->w_bits; - s->w_mask = s->w_size - 1; s->high_water = 0; /* nothing written to s->window yet */ @@ -156,7 +156,6 @@ struct ALIGNED_(64) internal_state { unsigned int w_size; /* LZ77 window size (32K by default) */ unsigned int w_bits; /* log2(w_size) (8..16) */ - unsigned int w_mask; /* w_size - 1 */ unsigned int lookahead; /* number of valid bytes ahead in window */ unsigned int high_water; @@ -404,6 +403,9 @@ static inline void put_uint64(deflate_state *s, uint64_t lld) { * distances are limited to MAX_DIST instead of WSIZE. */ +#define W_MASK(s) ((s)->w_size - 1) +/* Window mask: w_size is always a power of 2, so w_mask = w_size - 1 */ + #define WIN_INIT STD_MAX_MATCH /* Number of bytes after end of data in window to initialize in order to avoid memory checker errors from longest match routines */ diff --git a/insert_string_tpl.h b/insert_string_tpl.h index 04a9b0a6b6..e507fb5917 100644 --- a/insert_string_tpl.h +++ b/insert_string_tpl.h @@ -56,7 +56,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 & s->w_mask] = head; + s->prev[str & W_MASK(s)] = head; s->head[hm] = (Pos)str; } return head; @@ -80,7 +80,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 & s->w_mask] = head; + s->prev[str & W_MASK(s)] = head; s->head[hm] = (Pos)str; } return head; @@ -101,7 +101,7 @@ Z_FORCEINLINE static void INSERT_STRING(deflate_state *const s, uint32_t str, ui /* Local pointers to avoid indirection */ Pos *headp = s->head; Pos *prevp = s->prev; - const unsigned int w_mask = s->w_mask; + const unsigned int w_mask = W_MASK(s); for (Pos idx = (Pos)str; strstart < strend; idx++, strstart++) { uint32_t val, hm; diff --git a/match_tpl.h b/match_tpl.h index 94de125e4b..ffc22433bd 100644 --- a/match_tpl.h +++ b/match_tpl.h @@ -25,7 +25,7 @@ */ Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) { unsigned int strstart = s->strstart; - const unsigned wmask = s->w_mask; + const unsigned wmask = W_MASK(s); unsigned char *window = s->window; unsigned char *scan = window + strstart; Z_REGISTER unsigned char *mbase_start = window; diff --git a/test/benchmarks/benchmark_insert_string.cc b/test/benchmarks/benchmark_insert_string.cc index fb0f99e8e7..7a68fb5192 100644 --- a/test/benchmarks/benchmark_insert_string.cc +++ b/test/benchmarks/benchmark_insert_string.cc @@ -35,7 +35,6 @@ public: // Set up window parameters s->w_size = MAX_WSIZE; s->w_bits = 15; - s->w_mask = MAX_WSIZE - 1; s->window_size = TEST_WINDOW_SIZE; // Allocate window |
