summaryrefslogtreecommitdiff
path: root/lib/_http_agent.js
diff options
context:
space:
mode:
authorLucas Recknagel <lucas91@me.com>2019-11-12 15:30:48 +0000
committerMichaël Zasso <targos@protonmail.com>2019-11-22 21:30:31 +0100
commite1a63a9785ae1d74ae362dea1479d6f890e1d187 (patch)
tree0ef2d5be3b485daacea9f8c3db15b686fea6a621 /lib/_http_agent.js
parentc132035f7c44bf6b720dc5c7faa87517922cff31 (diff)
downloadandroid-node-v8-e1a63a9785ae1d74ae362dea1479d6f890e1d187.tar.gz
android-node-v8-e1a63a9785ae1d74ae362dea1479d6f890e1d187.tar.bz2
android-node-v8-e1a63a9785ae1d74ae362dea1479d6f890e1d187.zip
http: improve performance caused by primordials
Refs: https://github.com/nodejs/node/issues/29766 This works on destructuring primordials whithin libs/_http_agent PR-URL: https://github.com/nodejs/node/pull/30416 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Diffstat (limited to 'lib/_http_agent.js')
-rw-r--r--lib/_http_agent.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/_http_agent.js b/lib/_http_agent.js
index f8aa395aef..270569eab9 100644
--- a/lib/_http_agent.js
+++ b/lib/_http_agent.js
@@ -21,7 +21,13 @@
'use strict';
-const { Object } = primordials;
+const {
+ Object: {
+ setPrototypeOf: ObjectSetPrototypeOf,
+ keys: ObjectKeys,
+ values: ObjectValues
+ }
+} = primordials;
const net = require('net');
const EventEmitter = require('events');
@@ -129,8 +135,8 @@ function Agent(options) {
// Don't emit keylog events unless there is a listener for them.
this.on('newListener', maybeEnableKeylog);
}
-Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype);
-Object.setPrototypeOf(Agent, EventEmitter);
+ObjectSetPrototypeOf(Agent.prototype, EventEmitter.prototype);
+ObjectSetPrototypeOf(Agent, EventEmitter);
function maybeEnableKeylog(eventName) {
if (eventName === 'keylog') {
@@ -141,7 +147,7 @@ function maybeEnableKeylog(eventName) {
agent.emit('keylog', keylog, this);
};
// Existing sockets will start listening on keylog now.
- const sockets = Object.values(this.sockets);
+ const sockets = ObjectValues(this.sockets);
for (let i = 0; i < sockets.length; i++) {
sockets[i].on('keylog', this[kOnKeylog]);
}
@@ -381,7 +387,7 @@ 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 = Object.keys(set);
+ 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++) {