Slightly improved compression speed
git-svn-id: https://lz4.googlecode.com/svn/trunk@41 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
parent
70ba2c463f
commit
bf12ca9a1e
21
lz4.c
21
lz4.c
@ -160,6 +160,7 @@ int LZ4_compressCtx(void** ctx,
|
|||||||
|
|
||||||
BYTE* op = (BYTE*) dest;
|
BYTE* op = (BYTE*) dest;
|
||||||
|
|
||||||
|
const size_t DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
|
||||||
int len, length;
|
int len, length;
|
||||||
const int skipStrength = SKIPSTRENGTH;
|
const int skipStrength = SKIPSTRENGTH;
|
||||||
U32 forwardH;
|
U32 forwardH;
|
||||||
@ -227,13 +228,16 @@ _next_match:
|
|||||||
// Start Counting
|
// Start Counting
|
||||||
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified
|
ip+=MINMATCH; ref+=MINMATCH; // MinMatch verified
|
||||||
anchor = ip;
|
anchor = ip;
|
||||||
while (A32(ref) == A32(ip))
|
while (ip<matchlimit-3)
|
||||||
{
|
{
|
||||||
ip+=4; ref+=4;
|
int diff = A32(ref) ^ A32(ip);
|
||||||
if (ip>matchlimit-4) { ref -= ip - (matchlimit-3); ip = matchlimit-3; break; }
|
if (!diff) { ip+=4; ref+=4; continue; }
|
||||||
|
ip += DeBruijnBytePos[((U32)((diff & -diff) * 0x077CB531U)) >> 27];
|
||||||
|
goto _endCount;
|
||||||
}
|
}
|
||||||
if (A16(ref) == A16(ip)) { ip+=2; ref+=2; }
|
if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
|
||||||
if (*ref == *ip) ip++;
|
if ((ip<matchlimit) && (*ref == *ip)) ip++;
|
||||||
|
_endCount:
|
||||||
len = (ip - anchor);
|
len = (ip - anchor);
|
||||||
|
|
||||||
// Encode MatchLength
|
// Encode MatchLength
|
||||||
@ -298,6 +302,7 @@ int LZ4_compress64kCtx(void** ctx,
|
|||||||
|
|
||||||
BYTE* op = (BYTE*) dest;
|
BYTE* op = (BYTE*) dest;
|
||||||
|
|
||||||
|
const size_t DeBruijnBytePos[32] = { 0, 0, 3, 0, 3, 1, 3, 0, 3, 2, 2, 1, 3, 2, 0, 1, 3, 3, 1, 2, 2, 2, 2, 0, 3, 1, 2, 0, 1, 0, 1, 1 };
|
||||||
int len, length;
|
int len, length;
|
||||||
const int skipStrength = SKIPSTRENGTH;
|
const int skipStrength = SKIPSTRENGTH;
|
||||||
U32 forwardH;
|
U32 forwardH;
|
||||||
@ -366,9 +371,9 @@ _next_match:
|
|||||||
anchor = ip;
|
anchor = ip;
|
||||||
while (ip<matchlimit-3)
|
while (ip<matchlimit-3)
|
||||||
{
|
{
|
||||||
if (A32(ref) == A32(ip)) { ip+=4; ref+=4; continue; }
|
int diff = A32(ref) ^ A32(ip);
|
||||||
if (A16(ref) == A16(ip)) { ip+=2; ref+=2; }
|
if (!diff) { ip+=4; ref+=4; continue; }
|
||||||
if (*ref == *ip) ip++;
|
ip += DeBruijnBytePos[((U32)((diff & -diff) * 0x077CB531U)) >> 27];
|
||||||
goto _endCount;
|
goto _endCount;
|
||||||
}
|
}
|
||||||
if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
|
if ((ip<(matchlimit-1)) && (A16(ref) == A16(ip))) { ip+=2; ref+=2; }
|
||||||
|
Loading…
Reference in New Issue
Block a user