Bug 1453537 - 1. Use Map for GV modules; r=esawin

Map generally works better than object as key-value stores.

MozReview-Commit-ID: 3BEYcRUHpW7

--HG--
extra : rebase_source : cb3e5193e4cd74f059054e14d401087b5cde87ef
This commit is contained in:
Jim Chen 2018-04-12 16:10:14 -04:00
parent 686443f2a7
commit f0e0753749

View File

@ -27,23 +27,21 @@ XPCOMUtils.defineLazyGetter(this, "dump", () =>
var ModuleManager = {
init: function(aBrowser) {
this.browser = aBrowser;
this.modules = {};
this.modules = new Map();
},
add: function(aResource, aType, ...aArgs) {
this.remove(aType);
let scope = {};
ChromeUtils.import(aResource, scope);
this.modules[aType] = new scope[aType](
this.modules.set(aType, new scope[aType](
aType, window, this.browser, WindowEventDispatcher, ...aArgs
);
));
},
remove: function(aType) {
if (!(aType in this.modules)) {
return;
}
delete this.modules[aType];
this.modules.delete(aType);
}
};