mirror of
https://github.com/nodejs/node.git
synced 2024-11-28 22:46:31 +01:00
buffer: improve copy() performance
There is no need to create a slice when sourceEnd is out of bounds. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
parent
ea465faf4a
commit
339690ce9b
@ -257,7 +257,7 @@ function _copyActual(source, target, targetStart, sourceStart, sourceEnd) {
|
||||
if (nb > sourceLen)
|
||||
nb = sourceLen;
|
||||
|
||||
if (sourceStart !== 0 || sourceEnd !== source.length)
|
||||
if (sourceStart !== 0 || sourceEnd < source.length)
|
||||
source = new Uint8Array(source.buffer, source.byteOffset + sourceStart, nb);
|
||||
|
||||
target.set(source, targetStart);
|
||||
|
Loading…
Reference in New Issue
Block a user