summaryrefslogtreecommitdiffstats
path: root/lib/lz4opt.h
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2017-11-09 01:56:20 (GMT)
committerYann Collet <cyan@fb.com>2017-11-09 01:56:20 (GMT)
commitdc3ed5b6a7d9cc7d251a1942558e37793d5575b8 (patch)
treeb10772a2feadfe105e507b570aaa71d40f110ec5 /lib/lz4opt.h
parent63f6039fb37bd561c776a1fc4eb04bd9ea46dc83 (diff)
downloadlz4-dc3ed5b6a7d9cc7d251a1942558e37793d5575b8.zip
lz4-dc3ed5b6a7d9cc7d251a1942558e37793d5575b8.tar.gz
lz4-dc3ed5b6a7d9cc7d251a1942558e37793d5575b8.tar.bz2
added code comments
Diffstat (limited to 'lib/lz4opt.h')
-rw-r--r--lib/lz4opt.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/lz4opt.h b/lib/lz4opt.h
index 7f74df9..9917851 100644
--- a/lib/lz4opt.h
+++ b/lib/lz4opt.h
@@ -184,8 +184,13 @@ static int LZ4HC_compress_optimal (
DEBUGLOG(7, "rPos:%u[%u] vs [%u]%u",
cur, opt[cur].price, opt[cur+1].price, cur+1);
if (fullUpdate) {
- if ((opt[cur+1].price <= opt[cur].price) && (opt[cur+MINMATCH].price < opt[cur].price + 3/*min seq price*/)) continue;
+ /* not useful to search here if next position has same (or lower) cost */
+ if ( (opt[cur+1].price <= opt[cur].price)
+ /* in some cases, next position has same cost, but cost rises sharply after, so a small match would still be beneficial */
+ && (opt[cur+MINMATCH].price < opt[cur].price + 3/*min seq price*/) )
+ continue;
} else {
+ /* not useful to search here if next position has same (or lower) cost */
if (opt[cur+1].price <= opt[cur].price) continue;
}