diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/_http_agent.js | 21 | ||||
-rw-r--r-- | lib/_http_client.js | 2 | ||||
-rw-r--r-- | lib/_http_outgoing.js | 16 | ||||
-rw-r--r-- | lib/_http_server.js | 2 |
4 files changed, 27 insertions, 14 deletions
diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 69fdb819a3a..5e3298b594d 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -146,9 +146,8 @@ function maybeEnableKeylog(eventName) { agent.emit('keylog', keylog, this); }; // Existing sockets will start listening on keylog now. - const sockets = ObjectValues(this.sockets); - for (let i = 0; i < sockets.length; i++) { - sockets[i].on('keylog', this[kOnKeylog]); + for (const socket of ObjectValues(this.sockets)) { + socket.on('keylog', this[kOnKeylog]); } } } @@ -346,9 +345,7 @@ Agent.prototype.removeSocket = function removeSocket(s, options) { if (!s.writable) sets.push(this.freeSockets); - for (let sk = 0; sk < sets.length; sk++) { - const sockets = sets[sk]; - + for (const sockets of sets) { if (sockets[name]) { const index = sockets[name].indexOf(s); if (index !== -1) { @@ -383,14 +380,10 @@ Agent.prototype.reuseSocket = function reuseSocket(socket, req) { }; Agent.prototype.destroy = function destroy() { - const sets = [this.freeSockets, this.sockets]; - for (let s = 0; s < sets.length; s++) { - const set = sets[s]; - const keys = ObjectKeys(set); - for (let v = 0; v < keys.length; v++) { - const setName = set[keys[v]]; - for (let n = 0; n < setName.length; n++) { - setName[n].destroy(); + for (const set of [this.freeSockets, this.sockets]) { + for (const key of ObjectKeys(set)) { + for (const setName of set[key]) { + setName.destroy(); } } } diff --git a/lib/_http_client.js b/lib/_http_client.js index f024c7fc89b..79621661151 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -231,6 +231,8 @@ function ClientRequest(input, options, cb) { if (!headersArray) { if (options.headers) { const keys = ObjectKeys(options.headers); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (let i = 0; i < keys.length; i++) { const key = keys[i]; this.setHeader(key, options.headers[key]); diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index f40cf923f9b..36d3054eab0 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -166,6 +166,8 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headers', { } else if (typeof val === 'object') { const headers = this[kOutHeaders] = ObjectCreate(null); const keys = ObjectKeys(val); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < keys.length; ++i) { const name = keys[i]; headers[name.toLowerCase()] = [name, val[name]]; @@ -189,6 +191,8 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { if (headers !== null) { const out = ObjectCreate(null); const keys = ObjectKeys(headers); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < keys.length; ++i) { const key = keys[i]; const val = headers[key][0]; @@ -204,6 +208,8 @@ ObjectDefineProperty(OutgoingMessage.prototype, '_headerNames', { if (!headers) return; const keys = ObjectKeys(val); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < keys.length; ++i) { const header = headers[keys[i]]; if (header) @@ -224,6 +230,8 @@ OutgoingMessage.prototype._renderHeaders = function _renderHeaders() { if (headersMap !== null) { const keys = ObjectKeys(headersMap); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0, l = keys.length; i < l; i++) { const key = keys[i]; headers[headersMap[key][0]] = headersMap[key][1]; @@ -458,6 +466,8 @@ function processHeader(self, state, key, value, validate) { validateHeaderName(key); if (ArrayIsArray(value)) { if (value.length < 2 || !isCookieField(key)) { + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < value.length; i++) storeHeader(self, state, key, value[i], validate); return; @@ -559,6 +569,8 @@ OutgoingMessage.prototype.getHeaders = function getHeaders() { const ret = ObjectCreate(null); if (headers) { const keys = ObjectKeys(headers); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < keys.length; ++i) { const key = keys[i]; const val = headers[key][1]; @@ -700,6 +712,8 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { const keys = ObjectKeys(headers); const isArray = ArrayIsArray(headers); var field, value; + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0, l = keys.length; i < l; i++) { var key = keys[i]; if (isArray) { @@ -854,6 +868,8 @@ OutgoingMessage.prototype._flushOutput = function _flushOutput(socket) { const outputData = this.outputData; socket.cork(); let ret; + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (var i = 0; i < outputLength; i++) { const { data, encoding, callback } = outputData[i]; ret = socket.write(data, encoding, callback); diff --git a/lib/_http_server.js b/lib/_http_server.js index 7afd2c0cd3c..b31762b4c1e 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -263,6 +263,8 @@ function writeHead(statusCode, reason, obj) { let k; if (obj) { const keys = ObjectKeys(obj); + // Retain for(;;) loop for performance reasons + // Refs: https://github.com/nodejs/node/pull/30958 for (let i = 0; i < keys.length; i++) { k = keys[i]; if (k) this.setHeader(k, obj[k]); |