From: Nathan Moinvaziri Date: Mon, 26 Jan 2026 08:43:10 +0000 (-0800) Subject: Always use zng_ctz32 for W_BITS calculation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39bf6fdac6850a304ed19502f0d19e3a0c4a4a4c;p=thirdparty%2Fzlib-ng.git Always use zng_ctz32 for W_BITS calculation --- diff --git a/deflate.h b/deflate.h index 5235ce9d1..92d3d2269 100644 --- a/deflate.h +++ b/deflate.h @@ -392,27 +392,7 @@ static inline void put_uint64(deflate_state *s, uint64_t lld) { #define W_MASK(s) ((s)->w_size - 1) /* Window mask: w_size is always a power of 2, so w_mask = w_size - 1 */ -#ifdef HAVE_BUILTIN_CTZ -# define W_BITS(s) ((unsigned int)__builtin_ctz((s)->w_size)) -#else -/* Fallback for w_size which is always a power of 2 between 256 and 32768 */ -static inline unsigned int compute_w_bits(unsigned int w_size) { - /* Switch ordered by likelihood - most common first (MAX_WBITS=15 -> 32768) */ - switch (w_size) { - case 32768: return 15; /* MAX_WBITS default */ - case 16384: return 14; - case 8192: return 13; - case 4096: return 12; - case 2048: return 11; - case 1024: return 10; - case 512: return 9; - case 256: return 8; - } - Assert(w_size >= 256 && w_size <= 32768, "invalid w_size"); - return 0; -} -# define W_BITS(s) compute_w_bits((s)->w_size) -#endif +#define W_BITS(s) zng_ctz32((s)->w_size) /* Window bits: log2(w_size), computed from w_size since w_size is a power of 2 */ #define WIN_INIT STD_MAX_MATCH