Skip to content

Commit

Permalink
http: improve performance caused by primordials
Browse files Browse the repository at this point in the history
Refs: nodejs#29766

This works on destructuring primordials whithin libs/_http_agent
  • Loading branch information
lrecknagel committed Nov 12, 2019
1 parent cc6f99d commit 6e247e8
Showing 1 changed file with 9 additions and 4 deletions.
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

0 comments on commit 6e247e8

Please sign in to comment.