diff --git a/lib/buffer.js b/lib/buffer.js index c9f45d333886d3..509bb0b39c146e 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -348,13 +348,13 @@ Buffer.copyBytesFrom = function copyBytesFrom(view, offset, length) { const viewLength = TypedArrayPrototypeGetLength(view); if (viewLength === 0) { - return Buffer.alloc(0); + return new FastBuffer(); } if (offset !== undefined || length !== undefined) { if (offset !== undefined) { validateInteger(offset, 'offset', 0); - if (offset >= viewLength) return Buffer.alloc(0); + if (offset >= viewLength) return new FastBuffer(); } else { offset = 0; } @@ -1257,7 +1257,7 @@ if (internalBinding('config').hasIntl) { throw new ERR_INVALID_ARG_TYPE('source', ['Buffer', 'Uint8Array'], source); } - if (source.length === 0) return Buffer.alloc(0); + if (source.length === 0) return new FastBuffer(); fromEncoding = normalizeEncoding(fromEncoding) || fromEncoding; toEncoding = normalizeEncoding(toEncoding) || toEncoding;