From ff773bfcdebb75730eb0546c425030396168b6fb Mon Sep 17 00:00:00 2001 From: Yann Collet Date: Tue, 26 Jun 2018 17:24:41 -0700 Subject: [PATCH] zeroise freq table with memset() improves decoding speed by ~5% in github_users sample set --- lib/common/entropy_common.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/common/entropy_common.c b/lib/common/entropy_common.c index 33fd04bd..b12944e1 100644 --- a/lib/common/entropy_common.c +++ b/lib/common/entropy_common.c @@ -85,6 +85,8 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t } } assert(hbSize >= 4); + /* init */ + memset(normalizedCounter, 0, (*maxSVPtr+1) * sizeof(normalizedCounter[0])); /* all symbols not present in NCount have a frequency of 0 */ bitStream = MEM_readLE32(ip); nbBits = (bitStream & 0xF) + FSE_MIN_TABLELOG; /* extract tableLog */ if (nbBits > FSE_TABLELOG_ABSOLUTE_MAX) return ERROR(tableLog_tooLarge); @@ -156,11 +158,6 @@ size_t FSE_readNCount (short* normalizedCounter, unsigned* maxSVPtr, unsigned* t } } /* while ((remaining>1) & (charnum<=*maxSVPtr)) */ if (remaining != 1) return ERROR(corruption_detected); if (bitCount > 32) return ERROR(corruption_detected); - /* zeroise the rest */ - { unsigned symbNb = charnum; - for (symbNb=charnum; symbNb <= *maxSVPtr; symbNb++) - normalizedCounter[symbNb] = 0; - } *maxSVPtr = charnum-1; ip += (bitCount+7)>>3;