From 78d44582823828e32d5425457a8268c3bbae054d Mon Sep 17 00:00:00 2001 From: Szymon Marczak <36894700+szmarczak@users.noreply.github.com> Date: Fri, 2 Aug 2019 11:27:56 +0200 Subject: [PATCH] Memory nitpick --- source/agent.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/agent.js b/source/agent.js index 0f05ac0..524a780 100644 --- a/source/agent.js +++ b/source/agent.js @@ -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]; + } } }; @@ -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]; + } } } }