From: Nick Terrell Date: Mon, 25 Sep 2017 23:12:46 +0000 (-0700) Subject: [zstd] Backport kernel patch from @ColinIanKing X-Git-Tag: v1.3.2~3^2~32^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F862%2Fhead;p=thirdparty%2Fzstd.git [zstd] Backport kernel patch from @ColinIanKing * 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. --- diff --git a/lib/compress/fse_compress.c b/lib/compress/fse_compress.c index 599280b90..549c115d4 100644 --- a/lib/compress/fse_compress.c +++ b/lib/compress/fse_compress.c @@ -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);