minor refactoring

This commit is contained in:
Yann Collet 2016-06-29 13:21:23 +02:00
parent 3c03326004
commit c77c0c1086

View File

@ -495,7 +495,7 @@ FORCE_INLINE int LZ4_compress_generic(
size_t refDelta=0; size_t refDelta=0;
/* Init conditions */ /* Init conditions */
if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported input size, too large (or negative) */ if ((U32)inputSize > (U32)LZ4_MAX_INPUT_SIZE) return 0; /* Unsupported inputSize, too large (or negative) */
switch(dict) switch(dict)
{ {
case noDict: case noDict:
@ -559,8 +559,9 @@ FORCE_INLINE int LZ4_compress_generic(
/* Encode Literals */ /* Encode Literals */
{ unsigned const litLength = (unsigned)(ip - anchor); { unsigned const litLength = (unsigned)(ip - anchor);
token = op++; token = op++;
if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit))) if ((outputLimited) && /* Check output buffer overflow */
return 0; /* Check output limit */ (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit)))
return 0;
if (litLength >= RUN_MASK) { if (litLength >= RUN_MASK) {
int len = (int)litLength-RUN_MASK; int len = (int)litLength-RUN_MASK;
*token = (RUN_MASK<<ML_BITS); *token = (RUN_MASK<<ML_BITS);
@ -598,8 +599,9 @@ _next_match:
ip += MINMATCH + matchCode; ip += MINMATCH + matchCode;
} }
if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit))) if ( outputLimited && /* Check output buffer overflow */
return 0; /* Check output limit */ (unlikely(op + (1 + LASTLITERALS) + (matchCode>>8) > olimit)) )
return 0;
if (matchCode >= ML_MASK) { if (matchCode >= ML_MASK) {
*token += ML_MASK; *token += ML_MASK;
matchCode -= ML_MASK; matchCode -= ML_MASK;