Skip to content

Commit 6eb53e5

Browse files
mcollinaaddaleax
authored andcommitted
stream: avoid possible slow path w UInt8Array
A chunk validity checks verifie if a chunk is a UInt8Array. We should defer it as it might be very expensive in older Node.js platforms. PR-URL: #13956 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Timothy Gu <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 100ccf9 commit 6eb53e5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/_stream_writable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ function validChunk(stream, state, chunk, cb) {
248248
Writable.prototype.write = function(chunk, encoding, cb) {
249249
var state = this._writableState;
250250
var ret = false;
251-
var isBuf = Stream._isUint8Array(chunk) && !state.objectMode;
251+
var isBuf = !state.objectMode && Stream._isUint8Array(chunk);
252252

253253
if (isBuf && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
254254
chunk = Stream._uint8ArrayToBuffer(chunk);

0 commit comments

Comments
 (0)