Skip to content

Commit

Permalink
http: simplify sending header
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ronag authored and targos committed May 4, 2020
1 parent 7893bde commit a4ec01c
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions lib/_http_outgoing.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,19 +304,11 @@ OutgoingMessage.prototype._send = function _send(data, encoding, callback) {
data = this._header + data;
} else {
const header = this._header;
if (this.outputData.length === 0) {
this.outputData = [{
data: header,
encoding: 'latin1',
callback: null
}];
} else {
this.outputData.unshift({
data: header,
encoding: 'latin1',
callback: null
});
}
this.outputData.unshift({
data: header,
encoding: 'latin1',
callback: null
});
this.outputSize += header.length;
this._onPendingData(header.length);
}
Expand Down

0 comments on commit a4ec01c

Please sign in to comment.