mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
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:
parent
686443f2a7
commit
f0e0753749
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user