Remove window id lookup by using a map (#192)

This commit is contained in:
Jonathan Kingston 2017-02-17 11:19:57 +00:00 committed by GitHub
parent aae8d2c796
commit d2604bfb07

View file

@ -59,7 +59,7 @@ Cu.import("resource:///modules/CustomizableWidgets.jsm");
const ContainerService = { const ContainerService = {
_identitiesState: {}, _identitiesState: {},
_windowMap: {}, _windowMap: new Map(),
init(installation) { init(installation) {
// If we are just been installed, we must store some information for the // If we are just been installed, we must store some information for the
@ -767,17 +767,15 @@ const ContainerService = {
}, },
closeWindow(window) { closeWindow(window) {
const id = windowUtils.getInnerId(window); this._windowMap.delete(window);
delete this._windowMap[id];
}, },
_getOrCreateContainerWindow(window) { _getOrCreateContainerWindow(window) {
const id = windowUtils.getInnerId(window); if (!(this._windowMap.has(window))) {
if (!(id in this._windowMap)) { this._windowMap.set(window, new ContainerWindow(window));
this._windowMap[id] = new ContainerWindow(window);
} }
return this._windowMap[id]; return this._windowMap.get(window);
}, },
_refreshNeeded() { _refreshNeeded() {
@ -785,8 +783,8 @@ const ContainerService = {
}, },
_hideAllPanels() { _hideAllPanels() {
for (let id in this._windowMap) { // eslint-disable-line prefer-const for (let windowObject of this._windowMap.values()) { // eslint-disable-line prefer-const
this._windowMap[id].hidePanel(); windowObject.hidePanel();
} }
}, },
@ -860,7 +858,7 @@ const ContainerService = {
} }
// all the configuration must go away now. // 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 // Let's close all the container tabs (note: we don't care if containers
// are supported but the current FF version). // are supported but the current FF version).