Remove window id lookup by using a map (#192)
This commit is contained in:
parent
aae8d2c796
commit
d2604bfb07
1 changed files with 8 additions and 10 deletions
18
index.js
18
index.js
|
@ -59,7 +59,7 @@ Cu.import("resource:///modules/CustomizableWidgets.jsm");
|
|||
|
||||
const ContainerService = {
|
||||
_identitiesState: {},
|
||||
_windowMap: {},
|
||||
_windowMap: new Map(),
|
||||
|
||||
init(installation) {
|
||||
// If we are just been installed, we must store some information for the
|
||||
|
@ -767,17 +767,15 @@ const ContainerService = {
|
|||
},
|
||||
|
||||
closeWindow(window) {
|
||||
const id = windowUtils.getInnerId(window);
|
||||
delete this._windowMap[id];
|
||||
this._windowMap.delete(window);
|
||||
},
|
||||
|
||||
_getOrCreateContainerWindow(window) {
|
||||
const id = windowUtils.getInnerId(window);
|
||||
if (!(id in this._windowMap)) {
|
||||
this._windowMap[id] = new ContainerWindow(window);
|
||||
if (!(this._windowMap.has(window))) {
|
||||
this._windowMap.set(window, new ContainerWindow(window));
|
||||
}
|
||||
|
||||
return this._windowMap[id];
|
||||
return this._windowMap.get(window);
|
||||
},
|
||||
|
||||
_refreshNeeded() {
|
||||
|
@ -785,8 +783,8 @@ const ContainerService = {
|
|||
},
|
||||
|
||||
_hideAllPanels() {
|
||||
for (let id in this._windowMap) { // eslint-disable-line prefer-const
|
||||
this._windowMap[id].hidePanel();
|
||||
for (let windowObject of this._windowMap.values()) { // eslint-disable-line prefer-const
|
||||
windowObject.hidePanel();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -860,7 +858,7 @@ const ContainerService = {
|
|||
}
|
||||
|
||||
// all the configuration must go away now.
|
||||
this._windowMap = {};
|
||||
this._windowMap = new Map();
|
||||
|
||||
// Let's close all the container tabs (note: we don't care if containers
|
||||
// are supported but the current FF version).
|
||||
|
|
Loading…
Add table
Reference in a new issue