Skip to content

Commit a3decf5

Browse files
ronagtargos
authored andcommitted
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 51c3c8d commit a3decf5

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
@@ -289,19 +289,11 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
289289
data = this._header + data;
290290
} else {
291291
const header = this._header;
292-
if (this.outputData.length === 0) {
293-
this.outputData = [{
294-
data: header,
295-
encoding: 'latin1',
296-
callback: null
297-
}];
298-
} else {
299-
this.outputData.unshift({
300-
data: header,
301-
encoding: 'latin1',
302-
callback: null
303-
});
304-
}
292+
this.outputData.unshift({
293+
data: header,
294+
encoding: 'latin1',
295+
callback: null
296+
});
305297
this.outputSize += header.length;
306298
this._onPendingData(header.length);
307299
}

0 commit comments

Comments
 (0)