]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[easy] Rewrite rowHashLog computation 2612/head
authorNick Terrell <terrelln@fb.com>
Tue, 4 May 2021 18:43:20 +0000 (11:43 -0700)
committerNick Terrell <terrelln@fb.com>
Tue, 4 May 2021 18:43:20 +0000 (11:43 -0700)
`ZSTD_highbit32(1u << x) == x` when it isn't undefined behavior.

lib/compress/zstd_compress.c

index bf0a14888af954d78928b8d80aff668c7106d618..197e8ed8ac8c7145f94b3f44dc4224d109fd3715 100644 (file)
@@ -1761,7 +1761,7 @@ ZSTD_reset_matchState(ZSTD_matchState_t* ms,
         {   /* Switch to 32-entry rows if searchLog is 5 (or more) */
             U32 const rowLog = cParams->searchLog < 5 ? 4 : 5;
             assert(cParams->hashLog > rowLog);
-            ms->rowHashLog = ZSTD_highbit32((U32)1 << (cParams->hashLog - rowLog));
+            ms->rowHashLog = cParams->hashLog - rowLog;
         }
     }