summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Terrell <terrelln@fb.com>2019-07-31 06:40:58 (GMT)
committerNick Terrell <terrelln@fb.com>2019-07-31 17:17:26 (GMT)
commit38c3945de300851757d0dd76182ee28aaf8253a4 (patch)
tree3d80f89589db4dc076fcbcad5efb51319bb0c2de
parentbe1738aa46326e86e9c3bb1029abaadce45b8e72 (diff)
downloadlz4-38c3945de300851757d0dd76182ee28aaf8253a4.zip
lz4-38c3945de300851757d0dd76182ee28aaf8253a4.tar.gz
lz4-38c3945de300851757d0dd76182ee28aaf8253a4.tar.bz2
[lz4hc] Only allow chain swapping forwards
When the match is very long and found quickly, we can do matchLength * nbCompares iterations through the chain swapping, which can really slow down compression.
-rw-r--r--lib/lz4hc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c
index 596888a..0608ec6 100644
--- a/lib/lz4hc.c
+++ b/lib/lz4hc.c
@@ -314,7 +314,7 @@ LZ4HC_InsertAndGetWiderMatch (
if (matchIndex + (U32)longest <= ipIndex) {
U32 distanceToNextMatch = 1;
int pos;
- for (pos = 0; pos <= longest - MINMATCH; ++pos) {
+ for (pos = matchChainPos; pos <= longest - MINMATCH; ++pos) {
U32 const candidateDist = DELTANEXTU16(chainTable, matchIndex + (U32)pos);
if (candidateDist > distanceToNextMatch) {
distanceToNextMatch = candidateDist;