]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Optimize read_buf by removing indirection penalty
authorHans Kristian Rosbach <hk-git@circlestorm.org>
Thu, 21 Aug 2025 18:36:53 +0000 (20:36 +0200)
committerHans Kristian Rosbach <hk-git@circlestorm.org>
Sat, 23 Aug 2025 17:17:17 +0000 (19:17 +0200)
deflate_p.h

index 6f690702b2d658b5820228b898e28f982df3ebfa..37de31439d24c129b5c64fe950849efa9ee51bcf 100644 (file)
@@ -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);