summaryrefslogtreecommitdiffstats
path: root/lz4hc.c
diff options
context:
space:
mode:
authoryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2013-03-02 23:34:21 (GMT)
committeryann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd>2013-03-02 23:34:21 (GMT)
commit633c51904ebc1e3d3f51d4793d24f4f39ce579cf (patch)
tree3b5a358322f102126c21dfda179698ace6347f38 /lz4hc.c
parente898c9a79a91083805e9a733c2c0917aa7d24820 (diff)
downloadlz4-633c51904ebc1e3d3f51d4793d24f4f39ce579cf.zip
lz4-633c51904ebc1e3d3f51d4793d24f4f39ce579cf.tar.gz
lz4-633c51904ebc1e3d3f51d4793d24f4f39ce579cf.tar.bz2
- New cmake file, by Nobuhiro Iwamatsu, which can also produce shared and static libraries.
- Improved decoding speed, even more for 64-bits, and "safe" version - Slight speed increase for LZ4-HC - Pushed a useless parameter down the list in lz4.c git-svn-id: https://lz4.googlecode.com/svn/trunk@90 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
Diffstat (limited to 'lz4hc.c')
-rw-r--r--lz4hc.c53
1 files changed, 32 insertions, 21 deletions
diff --git a/lz4hc.c b/lz4hc.c
index 341a010..7324492 100644
--- a/lz4hc.c
+++ b/lz4hc.c
@@ -377,41 +377,29 @@ forceinline static int LZ4HC_InsertAndFindBestMatch (LZ4HC_Data_Structure* hc4,
const BYTE* ref;
INITBASE(base,hc4->base);
int nbAttempts=MAX_NB_ATTEMPTS;
- size_t ml=0;
+ size_t repl=0, ml=0;
+ U16 delta;
// HC4 match finder
LZ4HC_Insert(hc4, ip);
ref = HASH_POINTER(ip);
-#if 1
+#define REPEAT_OPTIMIZATION
+#ifdef REPEAT_OPTIMIZATION
+ // Detect repetitive sequences of length <= 4
if (ref >= ip-4) // potential repetition
{
if (A32(ref) == A32(ip)) // confirmed
{
- const U16 delta = (U16)(ip-ref);
- const BYTE* ptr = ip;
- const BYTE* end;
- ml = LZ4HC_CommonLength(ip+MINMATCH, ref+MINMATCH, matchlimit) + MINMATCH;
- end = ip + ml - (MINMATCH-1);
- while(ptr < end-delta)
- {
- DELTANEXT(ptr) = delta; // Pre-Load
- ptr++;
- }
- do
- {
- DELTANEXT(ptr) = delta;
- HashTable[HASH_VALUE(ptr)] = (ptr) - base; // Head of chain
- ptr++;
- } while(ptr < end);
- hc4->nextToUpdate = end;
+ delta = (U16)(ip-ref);
+ repl = ml = LZ4HC_CommonLength(ip+MINMATCH, ref+MINMATCH, matchlimit) + MINMATCH;
*matchpos = ref;
}
ref = GETNEXT(ref);
}
#endif
- while ((ref >= ip-MAX_DISTANCE) && (ref >= hc4->base) && (nbAttempts))
+ while ((ref >= ip-MAX_DISTANCE) && (nbAttempts))
{
nbAttempts--;
if (*(ref+ml) == *(ip+ml))
@@ -423,6 +411,29 @@ forceinline static int LZ4HC_InsertAndFindBestMatch (LZ4HC_Data_Structure* hc4,
ref = GETNEXT(ref);
}
+#ifdef REPEAT_OPTIMIZATION
+ // Complete table
+ if (repl)
+ {
+ const BYTE* ptr = ip;
+ const BYTE* end;
+
+ end = ip + repl - (MINMATCH-1);
+ while(ptr < end-delta)
+ {
+ DELTANEXT(ptr) = delta; // Pre-Load
+ ptr++;
+ }
+ do
+ {
+ DELTANEXT(ptr) = delta;
+ HashTable[HASH_VALUE(ptr)] = (ptr) - base; // Head of chain
+ ptr++;
+ } while(ptr < end);
+ hc4->nextToUpdate = end;
+ }
+#endif
+
return (int)ml;
}
@@ -440,7 +451,7 @@ forceinline static int LZ4HC_InsertAndGetWiderMatch (LZ4HC_Data_Structure* hc4,
LZ4HC_Insert(hc4, ip);
ref = HASH_POINTER(ip);
- while ((ref >= ip-MAX_DISTANCE) && (ref >= hc4->base) && (nbAttempts))
+ while ((ref >= ip-MAX_DISTANCE) && (nbAttempts))
{
nbAttempts--;
if (*(startLimit + longest) == *(ref - delta + longest))