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
This commit is contained in:
Florian Müllner 2019-06-30 01:02:34 +02:00 committed by Florian Müllner
parent 0bdd1b6fc4
commit e95f3febd6

View File

@ -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) {