]> git.ipfire.org Git - thirdparty/zlib-ng.git/commitdiff
Loop unroll for len >= 8 in crc32_copy_small.
authorNathan Moinvaziri <nathan@nathanm.com>
Thu, 15 Jan 2026 04:17:53 +0000 (20:17 -0800)
committerHans Kristian Rosbach <hk-github@circlestorm.org>
Thu, 29 Jan 2026 12:29:39 +0000 (13:29 +0100)
arch/generic/crc32_braid_c.c
crc32_p.h

index 0236fbcd4826348e0006046781ad062f7f42d1c5..0082770153b6c2a53f5e7790d512df3dcd955eb4 100644 (file)
@@ -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);
 }
 
index 37e9a4cf30841a34b3349019848d8317a30e2070..8f1d1d06c338a4d95ea2e9ea06a24f7f1adf3dff 100644 (file)
--- a/crc32_p.h
+++ b/crc32_p.h
 
 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;
     }