Skip to content

Commit d799c0f

Browse files
committed
http: simplify sending header
unshifting into an empty array is the same as creating a new array. PR-URL: #33200 Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Zeyu Yang <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 53eb264 commit d799c0f

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

lib/_http_outgoing.js

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,11 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
304304
data = this._header + data;
305305
} else {
306306
const header = this._header;
307-
if (this.outputData.length === 0) {
308-
this.outputData = [{
309-
data: header,
310-
encoding: 'latin1',
311-
callback: null
312-
}];
313-
} else {
314-
this.outputData.unshift({
315-
data: header,
316-
encoding: 'latin1',
317-
callback: null
318-
});
319-
}
307+
this.outputData.unshift({
308+
data: header,
309+
encoding: 'latin1',
310+
callback: null
311+
});
320312
this.outputSize += header.length;
321313
this._onPendingData(header.length);
322314
}

0 commit comments

Comments
 (0)