Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
http: improve performance caused by primordials
Refs: #29766

This works on destructuring primordials whithin libs/_http_agent
  • Loading branch information
lrecknagel committed Nov 12, 2019
commit 6e247e80905633557472de05f1c4b34da9ecf8e5
13 changes: 9 additions & 4 deletions lib/_http_agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@

'use strict';

const { Object } = primordials;
const {
Object: {
setPrototypeOf: ObjectSetPrototypeOf,
keys: ObjectKeys
}
} = primordials;

const net = require('net');
const EventEmitter = require('events');
Expand Down Expand Up @@ -125,8 +130,8 @@ function Agent(options) {
}
});
}
Object.setPrototypeOf(Agent.prototype, EventEmitter.prototype);
Object.setPrototypeOf(Agent, EventEmitter);
ObjectSetPrototypeOf(Agent.prototype, EventEmitter.prototype);
ObjectSetPrototypeOf(Agent, EventEmitter);

Agent.defaultMaxSockets = Infinity;

Expand Down Expand Up @@ -357,7 +362,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++) {
Expand Down