mirror of
https://github.com/facebook/zstd.git
synced 2025-03-06 16:56:49 +02:00
Change block delimiter removing to linear time approach
This commit is contained in:
parent
3c9b43da1d
commit
f782cac3d4
@ -2569,22 +2569,22 @@ size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs,
|
|||||||
ZSTD_customFree(dst, ZSTD_defaultCMem);
|
ZSTD_customFree(dst, ZSTD_defaultCMem);
|
||||||
|
|
||||||
if (format == ZSTD_sf_noBlockDelimiters) {
|
if (format == ZSTD_sf_noBlockDelimiters) {
|
||||||
size_t i = 0;
|
/* Remove all block delimiters and append them to the next sequence's literals
|
||||||
size_t totalSeqs = zc->seqCollector.seqIndex;
|
* and do not emit last literals at all
|
||||||
while(i < totalSeqs) {
|
*/
|
||||||
if (seqCollector.seqStart[i].offset == 0 && seqCollector.seqStart[i].matchLength == 0) {
|
size_t in = 0;
|
||||||
/* Merge the block boundary or last literals */
|
size_t out = 0;
|
||||||
if (i != totalSeqs-1) {
|
for (; in < zc->seqCollector.seqIndex; ++in) {
|
||||||
/* Add last literals to next sequence, then "delete" this sequence */
|
if (seqCollector.seqStart[in].offset == 0 && seqCollector.seqStart[in].matchLength == 0) {
|
||||||
seqCollector.seqStart[i+1].litLength += seqCollector.seqStart[i].litLength;
|
if (in != zc->seqCollector.seqIndex - 1) {
|
||||||
ZSTD_memmove(seqCollector.seqStart+i, seqCollector.seqStart+i+1, (totalSeqs-i-1)*sizeof(ZSTD_Sequence));
|
seqCollector.seqStart[in+1].litLength += seqCollector.seqStart[in].litLength;
|
||||||
}
|
}
|
||||||
totalSeqs--;
|
|
||||||
} else {
|
} else {
|
||||||
++i;
|
seqCollector.seqStart[out] = seqCollector.seqStart[in];
|
||||||
|
++out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zc->seqCollector.seqIndex = totalSeqs;
|
zc->seqCollector.seqIndex = out;
|
||||||
}
|
}
|
||||||
|
|
||||||
return zc->seqCollector.seqIndex;
|
return zc->seqCollector.seqIndex;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user