From 00681583a2bae6de69ec6b115da3c1bf65af8a8a Mon Sep 17 00:00:00 2001 From: cxl Date: Fri, 24 Oct 2014 06:51:53 +0000 Subject: [PATCH] .fix in lz4 git-svn-id: svn://ultimatepp.org/upp/trunk@7823 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/plugin/lz4/lib/lz4.c | 52 ++++++++++++++++++------------------- uppsrc/plugin/lz4/lib/lz4.h | 10 +++---- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/uppsrc/plugin/lz4/lib/lz4.c b/uppsrc/plugin/lz4/lib/lz4.c index d87c51c09..fc4975442 100644 --- a/uppsrc/plugin/lz4/lib/lz4.c +++ b/uppsrc/plugin/lz4/lib/lz4.c @@ -429,12 +429,18 @@ static unsigned LZ4_count(const BYTE* pIn, const BYTE* pRef, const BYTE* pInLimi } #ifdef LZ4_STATS -int matchOffsetStat[256]; -int matchLengthStat[1024]; -int matchLengthBig; -int litLengthStat[1024]; -int litLengthStatBig; -int literals; + +int lz4stat_LiteralLen; +int lz4stat_Matches; +int lz4stat_BigMatch; +int lz4stat_BigLiteral; + +#define STATCODE(x) x + +#else + +#define STATCODE(x) + #endif static int LZ4_compress_generic( @@ -542,13 +548,7 @@ static int LZ4_compress_generic( { /* Encode Literal length */ unsigned litLength = (unsigned)(ip - anchor); -#ifdef LZ4_STATS - if(litLength < 1024) - litLengthStat[litLength]++; - else - litLengthStatBig++; - literals += litLength; -#endif + STATCODE(lz4stat_LiteralLen += litLength;) token = op++; if ((outputLimited) && (unlikely(op + litLength + (2 + 1 + LASTLITERALS) + (litLength/255) > olimit))) return 0; /* Check output limit */ @@ -556,8 +556,12 @@ static int LZ4_compress_generic( { int len = (int)litLength-RUN_MASK; *token=(RUN_MASK<= 255 ; len-=255) *op++ = 255; + for(; len >= 255 ; len-=255) { + *op++ = 255; + STATCODE(lz4stat_BigLiteral++); + } *op++ = (BYTE)len; + STATCODE(lz4stat_BigLiteral++); } else *token = (BYTE)(litLength<> 8]++; -#endif /* Encode MatchLength */ { unsigned matchLength; @@ -597,22 +600,16 @@ _next_match: ip += MINMATCH + matchLength; } -#ifdef LZ4_STATS - if(matchLength + 4 < 1024) - matchLengthStat[matchLength + 4]++; - else - matchLengthBig++; -#endif - if (matchLength>=ML_MASK) { if ((outputLimited) && (unlikely(op + (1 + LASTLITERALS) + (matchLength>>8) > olimit))) return 0; /* Check output limit */ *token += ML_MASK; matchLength -= ML_MASK; - for (; matchLength >= 510 ; matchLength-=510) { *op++ = 255; *op++ = 255; } - if (matchLength >= 255) { matchLength-=255; *op++ = 255; } + for (; matchLength >= 510 ; matchLength-=510) { *op++ = 255; *op++ = 255; STATCODE(lz4stat_BigMatch+=2); } + if (matchLength >= 255) { matchLength-=255; *op++ = 255; STATCODE(lz4stat_BigMatch++); } *op++ = (BYTE)matchLength; + STATCODE(lz4stat_BigMatch++); } else *token += (BYTE)(matchLength); } @@ -644,7 +641,8 @@ _next_match: if ( ((dictIssue==dictSmall) ? (ref>=lowRefLimit) : 1) && (ref+MAX_DISTANCE>=ip) && (A32(ref+refDelta)==A32(ip)) ) - { token=op++; *token=0; litLengthStat[0]++; goto _next_match; } + { token=op++; *token=0; + goto _next_match; } /* Prepare next loop */ forwardH = LZ4_hashPosition(++ip, tableType); diff --git a/uppsrc/plugin/lz4/lib/lz4.h b/uppsrc/plugin/lz4/lib/lz4.h index faac8dad3..d2bee3a2f 100644 --- a/uppsrc/plugin/lz4/lib/lz4.h +++ b/uppsrc/plugin/lz4/lib/lz4.h @@ -322,12 +322,10 @@ int LZ4_decompress_fast_withPrefix64k (const char* source, char* dest, int origi #endif #ifdef LZ4_STATS -extern int matchOffsetStat[256]; -extern int matchLengthStat[1024]; -extern int matchLengthBig; -extern int litLengthStat[1024]; -extern int litLengthStatBig; -extern int literals; +extern int lz4stat_LiteralLen; +extern int lz4stat_Matches; +extern int lz4stat_BigMatch; +extern int lz4stat_BigLiteral; #endif #if defined (__cplusplus)