From 024f83c1e56de5b7784d51d990359ef283a1d48c Mon Sep 17 00:00:00 2001 From: "yann.collet.73@gmail.com" Date: Tue, 11 Dec 2012 01:38:32 +0000 Subject: Improved decoding speed, thanks to several contributions from Ludvig Strigeus (issues 49, 50 & 54) Removed unnecessary assignment within LZ4_uncompress_unknownSize() (reported by Shivram) git-svn-id: https://lz4.googlecode.com/svn/trunk@85 650e7d94-2a16-8b24-b05c-7c0b3f6821cd --- lz4.c | 63 +++++++++++++++++++++++++++++++++------------------------------ 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/lz4.c b/lz4.c index a651748..00d6f95 100644 --- a/lz4.c +++ b/lz4.c @@ -701,10 +701,13 @@ int LZ4_uncompress(const char* source, BYTE* const oend = op + osize; BYTE* cpy; - BYTE token; + unsigned token; - int len, length; - size_t dec[] ={0, 3, 2, 3, 0, 0, 0, 0}; + size_t length; + size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; +#if LZ4_ARCH64 + size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; +#endif // Main Loop @@ -712,7 +715,7 @@ int LZ4_uncompress(const char* source, { // get runlength token = *ip++; - if ((length=(token>>ML_BITS)) == RUN_MASK) { for (;(len=*ip++)==255;length+=255){} length += len; } + if ((length=(token>>ML_BITS)) == RUN_MASK) { size_t len; for (;(len=*ip++)==255;length+=255){} length += len; } // copy literals cpy = op+length; @@ -727,27 +730,26 @@ int LZ4_uncompress(const char* source, // get offset LZ4_READ_LITTLEENDIAN_16(ref,cpy,ip); ip+=2; - if (ref < (BYTE* const)dest) goto _output_error; // Error : offset create reference outside destination buffer + if unlikely(ref < (BYTE* const)dest) goto _output_error; // Error : offset create reference outside destination buffer // get matchlength if ((length=(token&ML_MASK)) == ML_MASK) { for (;*ip==255;length+=255) {ip++;} length += *ip++; } // copy repeated sequence - if unlikely(op-refoend-COPYLENGTH) @@ -787,14 +789,17 @@ int LZ4_uncompress_unknownOutputSize( BYTE* const oend = op + maxOutputSize; BYTE* cpy; - size_t dec[] ={0, 3, 2, 3, 0, 0, 0, 0}; + size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; +#if LZ4_ARCH64 + size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; +#endif // Main Loop while (ipoend-COPYLENGTH) -- cgit v0.12