(const BYTE*) source - dictCtx->currentOffset :
(const BYTE*) source - dictSize - currentOffset;
const ptrdiff_t dictDelta = dictionary ? dictEnd - (const BYTE*) source : 0;
+ const BYTE* dictLowLimit;
BYTE* op = (BYTE*) dest;
BYTE* const olimit = op + maxOutputSize;
lowLimit = (const BYTE*)source;
break;
}
+
+ dictLowLimit = dictionary ? dictionary : lowLimit;
+
if ((tableType == byU16) && (inputSize>=LZ4_64Klimit)) return 0; /* Size too large (not within 64K limit) */
if (inputSize<LZ4_minLength) goto _last_literals; /* Input too small, no compression (all literals) */
/* TODO: use precalc-ed hash? */
match = LZ4_getPosition(ip, dictCtx->hashTable, byU32, dictBase);
refDelta = dictDelta;
- lowLimit = dictionary;
+ lowLimit = dictLowLimit;
} else {
refDelta = 0;
lowLimit = (const BYTE*)source;
}
} else if (dictDirective==usingExtDict) {
- if (match < (const BYTE*)source && dictionary != NULL) {
+ if (match < (const BYTE*)source) {
refDelta = dictDelta;
- lowLimit = dictionary;
+ lowLimit = dictLowLimit;
} else {
refDelta = 0;
lowLimit = (const BYTE*)source;
/* Encode MatchLength */
{ unsigned matchCode;
- if ((dictDirective==usingExtDict || dictDirective==usingExtDictCtx) && (dictionary != NULL) && (lowLimit==dictionary)) {
+ if ((dictDirective==usingExtDict || dictDirective==usingExtDictCtx) && (dictionary != NULL) && (lowLimit==dictLowLimit)) {
const BYTE* limit;
match += refDelta;
limit = ip + (dictEnd-match);
/* TODO: use precalc-ed hash? */
match = LZ4_getPosition(ip, dictCtx->hashTable, byU32, dictBase);
refDelta = dictDelta;
- lowLimit = dictionary;
+ lowLimit = dictLowLimit;
} else {
refDelta = 0;
lowLimit = (const BYTE*)source;
}
} else if (dictDirective==usingExtDict) {
- if (match < (const BYTE*)source && dictionary != NULL) {
+ if (match < (const BYTE*)source) {
refDelta = dictDelta;
- lowLimit = dictionary;
+ lowLimit = dictLowLimit;
} else {
refDelta = 0;
lowLimit = (const BYTE*)source;