diff options
author | W. Felix Handte <w@felixhandte.com> | 2018-03-28 16:26:54 (GMT) |
---|---|---|
committer | W. Felix Handte <w@felixhandte.com> | 2018-04-20 00:54:35 (GMT) |
commit | 22db704a73e38a869d846fa52ddcbb0a214a6c43 (patch) | |
tree | 66231a3aebc645c7c270aaacf6e4bd8790b4da04 /lib | |
parent | 4f7b7a8ffa3032a64aa173f7d8bfb7c258316154 (diff) | |
download | lz4-22db704a73e38a869d846fa52ddcbb0a214a6c43.zip lz4-22db704a73e38a869d846fa52ddcbb0a214a6c43.tar.gz lz4-22db704a73e38a869d846fa52ddcbb0a214a6c43.tar.bz2 |
Shift Dict Limit Checks out of the Loop
Diffstat (limited to 'lib')
-rw-r--r-- | lib/lz4hc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/lz4hc.c b/lib/lz4hc.c index 85419f3..8ac650e 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -294,11 +294,11 @@ LZ4HC_InsertAndGetWiderMatch ( } } } } } /* while ((matchIndex>=lowLimit) && (matchIndex < (ip - base)) && (nbAttempts)) */ - if (dictCtx != NULL && nbAttempts) { + if (dictCtx != NULL && nbAttempts && ip - base - lowLimit < MAX_DISTANCE) { ptrdiff_t dictIndexDelta = dictCtx->base - dictCtx->end + lowLimit; dictMatchIndex = dictCtx->hashTable[LZ4HC_hashPtr(ip)]; matchIndex = dictMatchIndex + dictIndexDelta; - while (dictMatchIndex >= dictCtx->dictLimit && dictMatchIndex + dictCtx->base < dictCtx->end && dictMatchIndex + MAX_DISTANCE > ip - base - dictIndexDelta && nbAttempts--) { + while (dictMatchIndex + MAX_DISTANCE > ip - base - dictIndexDelta && nbAttempts--) { const BYTE* const matchPtr = dictCtx->base + dictMatchIndex; if (LZ4_read32(matchPtr) == pattern) { |