Skip to content

Commit 964adfa

Browse files
seishuncodebytere
authored andcommittedJun 7, 2020
buffer: improve copy() performance
There is no need to create a slice when sourceEnd is out of bounds. PR-URL: #33214 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Zeyu Yang <himself65@outlook.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 66dbaff commit 964adfa

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎lib/buffer.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
257257
if (nb > sourceLen)
258258
nb = sourceLen;
259259

260-
if (sourceStart !== 0 || sourceEnd !== source.length)
260+
if (sourceStart !== 0 || sourceEnd < source.length)
261261
source = new Uint8Array(source.buffer, source.byteOffset + sourceStart, nb);
262262

263263
target.set(source, targetStart);

0 commit comments

Comments
 (0)
Please sign in to comment.