minor optimization for ZSTD_compressSequencesAndLiterals()
does not need to track and update internal `litPtr`. note: does not measurably impact performance.
This commit is contained in:
@@ -742,13 +742,10 @@ ZSTD_storeSeqOnly(SeqStore_t* seqStorePtr,
|
|||||||
size_t matchLength)
|
size_t matchLength)
|
||||||
{
|
{
|
||||||
assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
|
assert((size_t)(seqStorePtr->sequences - seqStorePtr->sequencesStart) < seqStorePtr->maxNbSeq);
|
||||||
/* update seqStorePtr->lit, so that we know how many literals were or will be copied */
|
|
||||||
assert(seqStorePtr->maxNbLit <= 128 KB);
|
|
||||||
assert(seqStorePtr->lit + litLength <= seqStorePtr->litStart + seqStorePtr->maxNbLit);
|
|
||||||
seqStorePtr->lit += litLength;
|
|
||||||
|
|
||||||
/* literal Length */
|
/* literal Length */
|
||||||
if (litLength>0xFFFF) {
|
assert(litLength <= ZSTD_BLOCKSIZE_MAX);
|
||||||
|
if (UNLIKELY(litLength>0xFFFF)) {
|
||||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||||
seqStorePtr->longLengthType = ZSTD_llt_literalLength;
|
seqStorePtr->longLengthType = ZSTD_llt_literalLength;
|
||||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||||
@@ -759,9 +756,10 @@ ZSTD_storeSeqOnly(SeqStore_t* seqStorePtr,
|
|||||||
seqStorePtr->sequences[0].offBase = offBase;
|
seqStorePtr->sequences[0].offBase = offBase;
|
||||||
|
|
||||||
/* match Length */
|
/* match Length */
|
||||||
|
assert(matchLength <= ZSTD_BLOCKSIZE_MAX);
|
||||||
assert(matchLength >= MINMATCH);
|
assert(matchLength >= MINMATCH);
|
||||||
{ size_t const mlBase = matchLength - MINMATCH;
|
{ size_t const mlBase = matchLength - MINMATCH;
|
||||||
if (mlBase>0xFFFF) {
|
if (UNLIKELY(mlBase>0xFFFF)) {
|
||||||
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
assert(seqStorePtr->longLengthType == ZSTD_llt_none); /* there can only be a single long length */
|
||||||
seqStorePtr->longLengthType = ZSTD_llt_matchLength;
|
seqStorePtr->longLengthType = ZSTD_llt_matchLength;
|
||||||
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
seqStorePtr->longLengthPos = (U32)(seqStorePtr->sequences - seqStorePtr->sequencesStart);
|
||||||
@@ -811,6 +809,7 @@ ZSTD_storeSeq(SeqStore_t* seqStorePtr,
|
|||||||
} else {
|
} else {
|
||||||
ZSTD_safecopyLiterals(seqStorePtr->lit, literals, litEnd, litLimit_w);
|
ZSTD_safecopyLiterals(seqStorePtr->lit, literals, litEnd, litLimit_w);
|
||||||
}
|
}
|
||||||
|
seqStorePtr->lit += litLength;
|
||||||
|
|
||||||
ZSTD_storeSeqOnly(seqStorePtr, litLength, offBase, matchLength);
|
ZSTD_storeSeqOnly(seqStorePtr, litLength, offBase, matchLength);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user