From 2aebfb30b8d1a194e9198b8ce451833a1689141f Mon Sep 17 00:00:00 2001 From: Hans Kristian Rosbach Date: Thu, 21 Aug 2025 20:36:53 +0200 Subject: [PATCH] Optimize read_buf by removing indirection penalty --- deflate_p.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/deflate_p.h b/deflate_p.h index 6f690702..37de3143 100644 --- a/deflate_p.h +++ b/deflate_p.h @@ -117,6 +117,7 @@ static inline uint16_t bi_reverse(unsigned code, int len) { * See also flush_pending_inline(). */ Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf, unsigned size) { + deflate_state *s = strm->state; uint32_t len = MIN(strm->avail_in, size); if (len == 0) @@ -125,10 +126,10 @@ Z_FORCEINLINE static unsigned read_buf(PREFIX3(stream) *strm, unsigned char *buf if (!DEFLATE_NEED_CHECKSUM(strm)) { memcpy(buf, strm->next_in, len); #ifdef GZIP - } else if (strm->state->wrap == 2) { - FUNCTABLE_CALL(crc32_fold_copy)(&strm->state->crc_fold, buf, strm->next_in, len); + } else if (s->wrap == 2) { + FUNCTABLE_CALL(crc32_fold_copy)(&s->crc_fold, buf, strm->next_in, len); #endif - } else if (strm->state->wrap == 1) { + } else if (s->wrap == 1) { strm->adler = FUNCTABLE_CALL(adler32_fold_copy)(strm->adler, buf, strm->next_in, len); } else { memcpy(buf, strm->next_in, len); -- 2.47.3