Skip to content

Commit

Permalink
Memory nitpick
Browse files Browse the repository at this point in the history
  • Loading branch information
szmarczak committed Aug 2, 2019
1 parent 72207c9 commit 78d4458
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ class Agent extends EventEmitter {
// Our entry can be replaced. We cannot remove the new one.
if (Reflect.has(this.queue, normalizedOptions) && this.queue[normalizedOptions][normalizedAuthority] === entry) {
delete this.queue[normalizedOptions][normalizedAuthority];

if (Object.keys(this.queue[normalizedOptions]).length === 0) {
delete this.queue[normalizedOptions];
}
}
};

Expand Down Expand Up @@ -240,6 +244,10 @@ class Agent extends EventEmitter {

if (movedListeners.length === 0) {
delete this.queue[normalizedOptions][authority];

if (Object.keys(this.queue[normalizedOptions]).length === 0) {
delete this.queue[normalizedOptions];
}
}
}
}
Expand Down

0 comments on commit 78d4458

Please sign in to comment.