From e95f3febd6398fa56d363a1e13bc17af3de1f5d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 30 Jun 2019 01:02:34 +0200 Subject: [PATCH] ibusManager: Use Map to store engines This is a clear case of key->value mapping, so using the corresponding data type makes sense. https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/612 --- js/misc/ibusManager.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/misc/ibusManager.js b/js/misc/ibusManager.js index 338542a13..5a0d2906a 100644 --- a/js/misc/ibusManager.js +++ b/js/misc/ibusManager.js @@ -42,7 +42,7 @@ var IBusManager = class { this._candidatePopup = new IBusCandidatePopup.CandidatePopup(); this._panelService = null; - this._engines = {}; + this._engines = new Map(); this._ready = false; this._registerPropertiesId = 0; this._currentEngineName = null; @@ -73,7 +73,7 @@ var IBusManager = class { this._panelService = null; this._candidatePopup.setPanelService(null); - this._engines = {}; + this._engines.clear(); this._ready = false; this._registerPropertiesId = 0; this._currentEngineName = null; @@ -96,7 +96,7 @@ var IBusManager = class { if (enginesList) { for (let i = 0; i < enginesList.length; ++i) { let name = enginesList[i].get_name(); - this._engines[name] = enginesList[i]; + this._engines.set(name, enginesList[i]); } this._updateReadiness(); } else { @@ -150,8 +150,7 @@ var IBusManager = class { } _updateReadiness() { - this._ready = (Object.keys(this._engines).length > 0 && - this._panelService != null); + this._ready = this._engines.size > 0 && this._panelService != null; this.emit('ready', this._ready); } @@ -189,10 +188,10 @@ var IBusManager = class { } getEngineDesc(id) { - if (!this._ready || !this._engines.hasOwnProperty(id)) + if (!this._ready || !this._engines.has(id)) return null; - return this._engines[id]; + return this._engines.get(id); } setEngine(id, callback) {