Skip to content

Commit be72ebf

Browse files
committed
[perf] Optimize buffer copy in readBufferLengthEncodedCopy with subarray
1 parent dbd5472 commit be72ebf

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/io/packet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ class Packet {
233233

234234
readBufferLengthEncodedCopy() {
235235
const len = this.readUnsignedLength();
236-
if (len === null) return null;
236+
if (len === null) return null;
237237
this.pos += len;
238-
return Buffer.from(this.buf, this.pos - len, len);
238+
return Buffer.from(this.buf.subarray(this.pos - len, this.pos));
239239
}
240240

241241
readBufferRemaining() {

0 commit comments

Comments
 (0)