Simplify Match Limit Checks
Seems like a ~1.25% speedup.
This commit is contained in:
@@ -535,8 +535,7 @@ void ZSTD_dedicatedDictSearch_lazy_loadDictionary(ZSTD_matchState_t* ms, const B
|
|||||||
if (count == cacheSize) {
|
if (count == cacheSize) {
|
||||||
for (count = 0; count < chainLimit;) {
|
for (count = 0; count < chainLimit;) {
|
||||||
if (i < minChain) {
|
if (i < minChain) {
|
||||||
countBeyondMinChain++;
|
if (!i || countBeyondMinChain++ > cacheSize) {
|
||||||
if (countBeyondMinChain > cacheSize) {
|
|
||||||
/* only allow pulling `cacheSize` number of entries
|
/* only allow pulling `cacheSize` number of entries
|
||||||
* into the cache or chainTable beyond `minChain`,
|
* into the cache or chainTable beyond `minChain`,
|
||||||
* to replace the entries pulled out of the
|
* to replace the entries pulled out of the
|
||||||
@@ -688,10 +687,13 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|||||||
matchIndex = dms->hashTable[ddsIdx + ddsAttempt];
|
matchIndex = dms->hashTable[ddsIdx + ddsAttempt];
|
||||||
match = ddsBase + matchIndex;
|
match = ddsBase + matchIndex;
|
||||||
|
|
||||||
if (matchIndex < ddsLowestIndex) {
|
if (!matchIndex) {
|
||||||
return ml;
|
return ml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* guaranteed by table construction */
|
||||||
|
(void)ddsLowestIndex;
|
||||||
|
assert(matchIndex >= ddsLowestIndex);
|
||||||
assert(match+4 <= ddsEnd);
|
assert(match+4 <= ddsEnd);
|
||||||
if (MEM_read32(match) == MEM_read32(ip)) {
|
if (MEM_read32(match) == MEM_read32(ip)) {
|
||||||
/* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
/* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
||||||
@@ -727,10 +729,8 @@ size_t ZSTD_HcFindBestMatch_generic (
|
|||||||
matchIndex = dms->chainTable[chainIndex];
|
matchIndex = dms->chainTable[chainIndex];
|
||||||
match = ddsBase + matchIndex;
|
match = ddsBase + matchIndex;
|
||||||
|
|
||||||
if (matchIndex < ddsLowestIndex) {
|
/* guaranteed by table construction */
|
||||||
break;
|
assert(matchIndex >= ddsLowestIndex);
|
||||||
}
|
|
||||||
|
|
||||||
assert(match+4 <= ddsEnd);
|
assert(match+4 <= ddsEnd);
|
||||||
if (MEM_read32(match) == MEM_read32(ip)) {
|
if (MEM_read32(match) == MEM_read32(ip)) {
|
||||||
/* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
/* assumption : matchIndex <= dictLimit-4 (by table construction) */
|
||||||
|
|||||||
Reference in New Issue
Block a user