Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: optimize consumeEnd #2510

Merged
merged 12 commits into from
Dec 9, 2023
Prev Previous commit
Next Next commit
Update lib/api/readable.js
Co-authored-by: Robert Nagy <ronagy@icloud.com>
  • Loading branch information
tsctx and ronag authored Dec 8, 2023
commit be10ea7e11538c26ac07286296cd14634fad4188
5 changes: 4 additions & 1 deletion lib/api/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,10 @@ function consumeStart (consume) {
* @param {number} length
*/
function chunksDecode (chunks, length) {
const buffer = Buffer.concat(chunks, length)
if (chunks.length === 0 || length === 0) {
return ''
}
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks, length)
return buffer.utf8Slice(
0,
buffer.length >= 3 &&
Expand Down
Loading