]> git.ipfire.org Git - thirdparty/zstd.git/commitdiff
[zstd] Backport kernel patch from @ColinIanKing 862/head
authorNick Terrell <terrelln@fb.com>
Mon, 25 Sep 2017 23:12:46 +0000 (16:12 -0700)
committerNick Terrell <terrelln@fb.com>
Mon, 25 Sep 2017 23:18:23 +0000 (16:18 -0700)
* Make the U32 table in `FSE_normalizeCount()` static.
* Patch from https://lkml.kernel.org/r/20170922145946.14316-1-colin.king@canonical.com.
* Clang makes non-static tables static anyways. gcc however, does [weird things](https://godbolt.org/g/fvTcED).
* Benchmarks showed no difference in speed.

lib/compress/fse_compress.c

index 599280b90ca37dfdf688dab243e1be9f99f5dc66..549c115d4238963331454e67a2f50ff34993f309 100644 (file)
@@ -582,7 +582,7 @@ size_t FSE_normalizeCount (short* normalizedCounter, unsigned tableLog,
     if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);   /* Unsupported size */
     if (tableLog < FSE_minTableLog(total, maxSymbolValue)) return ERROR(GENERIC);   /* Too small tableLog, compression potentially impossible */
 
-    {   U32 const rtbTable[] = {     0, 473195, 504333, 520860, 550000, 700000, 750000, 830000 };
+    {   static U32 const rtbTable[] = {     0, 473195, 504333, 520860, 550000, 700000, 750000, 830000 };
         U64 const scale = 62 - tableLog;
         U64 const step = ((U64)1<<62) / total;   /* <== here, one division ! */
         U64 const vStep = 1ULL<<(scale-20);