Improved speed under Visual

git-svn-id: https://lz4.googlecode.com/svn/trunk@73 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2012-08-03 14:33:12 +00:00
parent 89921dd39e
commit 19a078b132
2 changed files with 39 additions and 1 deletions

38
lz4.c
View File

@ -402,8 +402,27 @@ inline int LZ4_compressCtx(void** ctx,
length = ip - anchor; length = ip - anchor;
token = op++; token = op++;
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit
#ifdef _MSC_VER
if (length>=(int)RUN_MASK)
{
int len = length-RUN_MASK;
*token=(RUN_MASK<<ML_BITS);
if (len>254)
{
do { *op++ = 255; len -= 255; } while (len>254);
*op++ = (BYTE)len;
memcpy(op, anchor, length);
op += length;
goto _next_match;
}
else
*op++ = (BYTE)len;
}
else *token = (length<<ML_BITS);
#else
if (length>=(int)RUN_MASK) { *token=(RUN_MASK<<ML_BITS); len = length-RUN_MASK; for(; len > 254 ; len-=255) *op++ = 255; *op++ = (BYTE)len; } if (length>=(int)RUN_MASK) { *token=(RUN_MASK<<ML_BITS); len = length-RUN_MASK; for(; len > 254 ; len-=255) *op++ = 255; *op++ = (BYTE)len; }
else *token = (length<<ML_BITS); else *token = (length<<ML_BITS);
#endif
// Copy Literals // Copy Literals
LZ4_BLINDCOPY(anchor, op, length); LZ4_BLINDCOPY(anchor, op, length);
@ -547,8 +566,27 @@ inline int LZ4_compress64kCtx(void** ctx,
length = ip - anchor; length = ip - anchor;
token = op++; token = op++;
if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit if unlikely(op + length + (2 + 1 + LASTLITERALS) + (length>>8) >= oend) return 0; // Check output limit
#ifdef _MSC_VER
if (length>=(int)RUN_MASK)
{
int len = length-RUN_MASK;
*token=(RUN_MASK<<ML_BITS);
if (len>254)
{
do { *op++ = 255; len -= 255; } while (len>254);
*op++ = (BYTE)len;
memcpy(op, anchor, length);
op += length;
goto _next_match;
}
else
*op++ = (BYTE)len;
}
else *token = (length<<ML_BITS);
#else
if (length>=(int)RUN_MASK) { *token=(RUN_MASK<<ML_BITS); len = length-RUN_MASK; for(; len > 254 ; len-=255) *op++ = 255; *op++ = (BYTE)len; } if (length>=(int)RUN_MASK) { *token=(RUN_MASK<<ML_BITS); len = length-RUN_MASK; for(; len > 254 ; len-=255) *op++ = 255; *op++ = (BYTE)len; }
else *token = (length<<ML_BITS); else *token = (length<<ML_BITS);
#endif
// Copy Literals // Copy Literals
LZ4_BLINDCOPY(anchor, op, length); LZ4_BLINDCOPY(anchor, op, length);

2
lz4.h
View File

@ -49,7 +49,7 @@ int LZ4_uncompress (const char* source, char* dest, int osize);
LZ4_compress() : LZ4_compress() :
Compresses 'isize' bytes from 'source' into 'dest'. Compresses 'isize' bytes from 'source' into 'dest'.
Destination buffer must be already allocated, Destination buffer must be already allocated,
its minimum size must handle worst cases situations (input data not compressible) and must be sized to handle worst cases situations (input data not compressible)
Worst case size evaluation is provided by macro LZ4_compressBound() Worst case size evaluation is provided by macro LZ4_compressBound()
isize : is the input size. Max supported value is ~1.9GB isize : is the input size. Max supported value is ~1.9GB