summaryrefslogtreecommitdiffstats
path: root/lib/lz4opt.h
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-12-22 07:07:25 (GMT)
committerYann Collet <cyan@fb.com>2017-12-22 07:07:25 (GMT)
commit9753ac4c91b926114ae636d1d7103dd24e5c0f57 (patch)
tree84b09d9af6a2d1edc9493ed7fe9e89ac324e3f93 /lib/lz4opt.h
parent8a9c8e73241672c1db29be454a9b8388bfde5034 (diff)
downloadlz4-9753ac4c91b926114ae636d1d7103dd24e5c0f57.zip
lz4-9753ac4c91b926114ae636d1d7103dd24e5c0f57.tar.gz
lz4-9753ac4c91b926114ae636d1d7103dd24e5c0f57.tar.bz2
conditional pattern analysis
Pattern analysis (currently limited to long ranges of identical bytes) is actually detrimental to performance when `nbSearches` is low. Reason is : `nbSearches` provides a built-in protection for these cases. The problem with patterns is that they dramatically increase the number of candidates to visit. But with a low nbSearches, the match finder just aborts early. In such cases, pattern analysis adds some complexity without reducing total nb of candidates. It actually increases compression ratio a little bit, by filtering only "good" candidates, but at a measurable speed cost, so it's not a good trade-off. This patch makes pattern analysis optional. It's enabled for levels 8+ only.
Diffstat (limited to 'lib/lz4opt.h')
-rw-r--r--lib/lz4opt.h4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index 9917851..6c15598 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -85,7 +85,9 @@ LZ4HC_match_t LZ4HC_FindLongerMatch(LZ4HC_CCtx_internal* const ctx,
/* note : LZ4HC_InsertAndGetWiderMatch() is able to modify the starting position of a match (*startpos),
* but this won't be the case here, as we define iLowLimit==ip,
* so LZ4HC_InsertAndGetWiderMatch() won't be allowed to search past ip */
- int const matchLength = LZ4HC_InsertAndGetWiderMatch(ctx, ip, ip, iHighLimit, minLen, &matchPtr, &ip, nbSearches);
+ int const matchLength = LZ4HC_InsertAndGetWiderMatch(ctx,
+ ip, ip, iHighLimit, minLen, &matchPtr, &ip,
+ nbSearches, 1 /* patternAnalysis */);
if (matchLength <= minLen) return match;
match.len = matchLength;
match.off = (int)(ip-matchPtr);