Skip to content

Commit c9737b3

Browse files
committed
buffer: retun fastbuffer directly instead of buffer.alloc(0)
1 parent 2bda7cb commit c9737b3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/buffer.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ Buffer.copyBytesFrom = function copyBytesFrom(view, offset, length) {
348348

349349
const viewLength = TypedArrayPrototypeGetLength(view);
350350
if (viewLength === 0) {
351-
return Buffer.alloc(0);
351+
return new FastBuffer();
352352
}
353353

354354
if (offset !== undefined || length !== undefined) {
355355
if (offset !== undefined) {
356356
validateInteger(offset, 'offset', 0);
357-
if (offset >= viewLength) return Buffer.alloc(0);
357+
if (offset >= viewLength) return new FastBuffer();
358358
} else {
359359
offset = 0;
360360
}
@@ -1257,7 +1257,7 @@ if (internalBinding('config').hasIntl) {
12571257
throw new ERR_INVALID_ARG_TYPE('source',
12581258
['Buffer', 'Uint8Array'], source);
12591259
}
1260-
if (source.length === 0) return Buffer.alloc(0);
1260+
if (source.length === 0) return new FastBuffer();
12611261

12621262
fromEncoding = normalizeEncoding(fromEncoding) || fromEncoding;
12631263
toEncoding = normalizeEncoding(toEncoding) || toEncoding;

0 commit comments

Comments
 (0)