From 868d49b64d09b3d90f9f33ab778b5253d746432f Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Fri, 1 May 2020 17:17:37 +0200 Subject: [PATCH] http: simplify sending header MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unshifting into an empty array is the same as creating a new array. PR-URL: https://github.com/nodejs/node/pull/33200 Reviewed-By: Juan José Arboleda Reviewed-By: James M Snell Reviewed-By: Zeyu Yang Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- lib/_http_outgoing.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 49f6e57fb1c6fd..606c3da9bd75fc 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -289,19 +289,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); }