Perf: replace sha256 w/ xxhash

This commit is contained in:
SukkaW
2024-10-08 21:32:56 +08:00
parent 14ed4c01e5
commit 4f76dd089a
4 changed files with 30 additions and 61 deletions

View File

@@ -48,17 +48,19 @@ export class TextLineStream extends TransformStream<string, string> {
}
}
if (lfIndex !== -1) {
let crOrLfIndex = lfIndex;
if (chunk[lfIndex - 1] === '\r') {
crOrLfIndex--;
}
controller.enqueue(chunk.slice(chunkIndex, crOrLfIndex));
chunkIndex = lfIndex + 1;
continue;
if (lfIndex === -1) {
// we can no longer find a line break in the chunk, break the current loop
break;
}
break;
// enqueue current line, and loop again to find next line
let crOrLfIndex = lfIndex;
if (chunk[lfIndex - 1] === '\r') {
crOrLfIndex--;
}
controller.enqueue(chunk.slice(chunkIndex, crOrLfIndex));
chunkIndex = lfIndex + 1;
continue;
}
__buf = chunk.slice(chunkIndex);