mirror of
https://github.com/facebook/zstd.git
synced 2025-10-20 00:04:34 -04:00
minor refactor : more accurate variable scope
This commit is contained in:
parent
b19d5d76ec
commit
16871680e3
@ -110,7 +110,6 @@ void FSE_freeDTable (FSE_DTable* dt)
|
|||||||
|
|
||||||
size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
|
size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned maxSymbolValue, unsigned tableLog)
|
||||||
{
|
{
|
||||||
FSE_DTableHeader DTableH;
|
|
||||||
void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */
|
void* const tdPtr = dt+1; /* because *dt is unsigned, 32-bits aligned on 32-bits */
|
||||||
FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr);
|
FSE_DECODE_TYPE* const tableDecode = (FSE_DECODE_TYPE*) (tdPtr);
|
||||||
U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1];
|
U16 symbolNext[FSE_MAX_SYMBOL_VALUE+1];
|
||||||
@ -124,19 +123,21 @@ size_t FSE_buildDTable(FSE_DTable* dt, const short* normalizedCounter, unsigned
|
|||||||
if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
|
if (tableLog > FSE_MAX_TABLELOG) return ERROR(tableLog_tooLarge);
|
||||||
|
|
||||||
/* Init, lay down lowprob symbols */
|
/* Init, lay down lowprob symbols */
|
||||||
DTableH.tableLog = (U16)tableLog;
|
{ FSE_DTableHeader DTableH;
|
||||||
DTableH.fastMode = 1;
|
DTableH.tableLog = (U16)tableLog;
|
||||||
{ S16 const largeLimit= (S16)(1 << (tableLog-1));
|
DTableH.fastMode = 1;
|
||||||
U32 s;
|
{ S16 const largeLimit= (S16)(1 << (tableLog-1));
|
||||||
for (s=0; s<maxSV1; s++) {
|
U32 s;
|
||||||
if (normalizedCounter[s]==-1) {
|
for (s=0; s<maxSV1; s++) {
|
||||||
tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s;
|
if (normalizedCounter[s]==-1) {
|
||||||
symbolNext[s] = 1;
|
tableDecode[highThreshold--].symbol = (FSE_FUNCTION_TYPE)s;
|
||||||
} else {
|
symbolNext[s] = 1;
|
||||||
if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
|
} else {
|
||||||
symbolNext[s] = normalizedCounter[s];
|
if (normalizedCounter[s] >= largeLimit) DTableH.fastMode=0;
|
||||||
} } }
|
symbolNext[s] = normalizedCounter[s];
|
||||||
memcpy(dt, &DTableH, sizeof(DTableH));
|
} } }
|
||||||
|
memcpy(dt, &DTableH, sizeof(DTableH));
|
||||||
|
}
|
||||||
|
|
||||||
/* Spread symbols */
|
/* Spread symbols */
|
||||||
{ U32 const tableMask = tableSize-1;
|
{ U32 const tableMask = tableSize-1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user