extensionSystem: Always disable multiple extensions in reverse order
Since disabling an extension will lead to disabling and re-enabling all following extensions in the list, always disable multiple extensions by looping through the list in reverse order. This lowers the execution time of the event handlers quite a bit if many extensions are installed. Thanks to Philippe Troin for identifying the problem and proposing the initial patch to change the extension order when reloading. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/177 https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/96
This commit is contained in:
parent
9698ff491a
commit
bdcf3037ca
@ -400,9 +400,9 @@ var ExtensionManager = class {
|
|||||||
|
|
||||||
// Find and disable all the newly disabled extensions: UUIDs found in the
|
// Find and disable all the newly disabled extensions: UUIDs found in the
|
||||||
// old setting, but not in the new one.
|
// old setting, but not in the new one.
|
||||||
this._enabledExtensions.filter(
|
this._extensionOrder.filter(
|
||||||
item => !newEnabledExtensions.includes(item)
|
uuid => !newEnabledExtensions.includes(uuid)
|
||||||
).forEach(uuid => {
|
).reverse().forEach(uuid => {
|
||||||
this._callExtensionDisable(uuid);
|
this._callExtensionDisable(uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -417,20 +417,19 @@ var ExtensionManager = class {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_onVersionValidationChanged() {
|
_onVersionValidationChanged() {
|
||||||
// we want to reload all extensions, but only enable
|
// Disabling extensions modifies the order array, so use a copy
|
||||||
// extensions when allowed by the sessionMode, so
|
let extensionOrder = this._extensionOrder.slice();
|
||||||
// temporarily disable them all
|
|
||||||
this._enabledExtensions = [];
|
|
||||||
|
|
||||||
// The loop modifies the extensions map, so iterate over a copy
|
// Disable enabled extensions in the reverse order first to avoid
|
||||||
let extensions = [...this._extensions.values()];
|
// the "rebasing" done in _callExtensionDisable...
|
||||||
for (let extension of extensions)
|
extensionOrder.slice().reverse().forEach(uuid => {
|
||||||
this.reloadExtension(extension);
|
this._callExtensionDisable(uuid);
|
||||||
this._enabledExtensions = this._getEnabledExtensions();
|
|
||||||
|
|
||||||
this._enabledExtensions.forEach(uuid => {
|
|
||||||
this._callExtensionEnable(uuid);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ...and then reload and enable extensions in the correct order again.
|
||||||
|
[...this._extensions.values()].sort((a, b) => {
|
||||||
|
return extensionOrder.indexOf(a.uuid) - extensionOrder.indexOf(b.uuid);
|
||||||
|
}).forEach(extension => this.reloadExtension(extension));
|
||||||
}
|
}
|
||||||
|
|
||||||
_loadExtensions() {
|
_loadExtensions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user