From: Nathan Moinvaziri Date: Thu, 15 Jan 2026 04:17:53 +0000 (-0800) Subject: Loop unroll for len >= 8 in crc32_copy_small. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a454c2af8fd2c7b64a30c151d7f5f3a070f0889a;p=thirdparty%2Fzlib-ng.git Loop unroll for len >= 8 in crc32_copy_small. --- diff --git a/arch/generic/crc32_braid_c.c b/arch/generic/crc32_braid_c.c index 0236fbcd4..008277015 100644 --- a/arch/generic/crc32_braid_c.c +++ b/arch/generic/crc32_braid_c.c @@ -200,10 +200,6 @@ Z_INTERNAL uint32_t crc32_braid_internal(uint32_t c, const uint8_t *buf, size_t #endif /* BRAID_W */ /* Complete the computation of the CRC on any remaining bytes. */ - while (len >= 8) { - len -= 8; - CRC_DO8; - } return crc32_copy_small(c, NULL, buf, len, 0); } diff --git a/crc32_p.h b/crc32_p.h index 37e9a4cf3..8f1d1d06c 100644 --- a/crc32_p.h +++ b/crc32_p.h @@ -13,12 +13,14 @@ Z_FORCEINLINE static uint32_t crc32_copy_small(uint32_t crc, uint8_t *dst, const uint8_t *buf, size_t len, const int COPY) { uint32_t c = crc; - - while (len) { - len--; - if (COPY) { - *dst++ = *buf; - } + if (COPY) { + memcpy(dst, buf, len); + } + while (len >= 8) { + len -= 8; + CRC_DO8; + } + while (len--) { CRC_DO1; }