From 8ccc9f5e7c9d9db3d533da2c8b8b9e5a703b0d5a Mon Sep 17 00:00:00 2001 From: "\"J. Ryan Stinnett\"" Date: Mon, 17 Mar 2014 12:02:00 +0100 Subject: [PATCH] Bug 982322 - Part 4: Save paths on each node. r=ochameau --- browser/devtools/app-manager/content/template.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/browser/devtools/app-manager/content/template.js b/browser/devtools/app-manager/content/template.js index a7803de7f22..ec11e984ced 100644 --- a/browser/devtools/app-manager/content/template.js +++ b/browser/devtools/app-manager/content/template.js @@ -142,13 +142,15 @@ Template.prototype = { }, _unregisterNodes: function(nodes) { - for (let [registeredPath, set] of this._nodeListeners) { - for (let e of nodes) { + for (let e of nodes) { + for (let registeredPath of e.registeredPaths) { + let set = this._nodeListeners.get(registeredPath); set.delete(e); + if (set.size === 0) { + this._nodeListeners.delete(registeredPath); + } } - if (set.size == 0) { - this._nodeListeners.delete(registeredPath); - } + e.registeredPaths = null; } }, @@ -240,6 +242,8 @@ Template.prototype = { this._registerNode(path, e); } } + // Store all the paths on the node, to speed up unregistering later + e.registeredPaths = paths; } catch(exception) { console.error("Invalid template: " + e.outerHTML + " (" + exception + ")"); }