Skip to content

Commit cae2051

Browse files
seishuncodebytere
authored andcommittedMay 11, 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 <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent eedc131 commit cae2051

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)