Introduce, implement, and call ZSTD_ldm_countBackwardsMatch_2segments()
This commit is contained in:
parent
8c46c1d851
commit
bf0d559449
@ -154,6 +154,26 @@ static size_t ZSTD_ldm_countBackwardsMatch(
|
||||
return matchLength;
|
||||
}
|
||||
|
||||
/** ZSTD_ldm_countBackwardsMatch_2segments() :
|
||||
* Returns the number of bytes that match backwards from pMatch,
|
||||
* even with the backwards match spanning 2 different segments.
|
||||
*
|
||||
* On reaching `pMatchBase`, start counting from mEnd */
|
||||
static size_t ZSTD_ldm_countBackwardsMatch_2segments(
|
||||
const BYTE* pIn, const BYTE* pAnchor,
|
||||
const BYTE* pMatch, const BYTE* pMatchBase, const BYTE* mEnd)
|
||||
{
|
||||
const BYTE* const vBegin = MAX(pIn - (pMatch - pMatchBase), pAnchor);
|
||||
size_t const matchLength = ZSTD_ldm_countBackwardsMatch(pIn, vBegin, pMatch, pMatchBase);
|
||||
if (pMatch - matchLength != pMatchBase) {
|
||||
return matchLength;
|
||||
}
|
||||
DEBUGLOG(7, "ZSTD_ldm_countBackwardsMatch_2segments: found a 2-parts backwards match (current length==%zu)", matchLength);
|
||||
DEBUGLOG(7, "distance from pMatch to start = %zi", pMatch - pMatchBase);
|
||||
DEBUGLOG(7, "final backwards match length = %zu", matchLength + ZSTD_ldm_countBackwardsMatch(pIn - matchLength, pAnchor, mEnd, pMatchBase));
|
||||
return matchLength + ZSTD_ldm_countBackwardsMatch(pIn - matchLength, pAnchor, mEnd, pMatchBase);
|
||||
}
|
||||
|
||||
/** ZSTD_ldm_fillFastTables() :
|
||||
*
|
||||
* Fills the relevant tables for the ZSTD_fast and ZSTD_dfast strategies.
|
||||
@ -329,8 +349,8 @@ static size_t ZSTD_ldm_generateSequences_internal(
|
||||
continue;
|
||||
}
|
||||
curBackwardMatchLength =
|
||||
ZSTD_ldm_countBackwardsMatch(ip, anchor, pMatch,
|
||||
lowMatchPtr);
|
||||
ZSTD_ldm_countBackwardsMatch_2segments(ip, anchor, pMatch,
|
||||
lowMatchPtr, dictEnd);
|
||||
curTotalMatchLength = curForwardMatchLength +
|
||||
curBackwardMatchLength;
|
||||
} else { /* !extDict */
|
||||
|
Loading…
x
Reference in New Issue
Block a user