[gnome-shell/wip/carlosg/less-get-all-calls] appDisplay: Reduce g_app_info_get_all() calls
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/less-get-all-calls] appDisplay: Reduce g_app_info_get_all() calls
- Date: Mon, 3 Dec 2018 12:48:37 +0000 (UTC)
commit 0eb7a4a42d387ecfcc0b67a897eeabcd2ef385fd
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Dec 3 13:18:19 2018 +0100
appDisplay: Reduce g_app_info_get_all() calls
Whenever the AllView needs (re)populating, we used to do one general
g_app_info_get_all() to get all GAppInfo, plus one per app folder in order
to check the ones that fall within that category. This calls results in a
fair amount of I/O blocking the main loop.
In order to ease this, keep the GAppInfo list around in AllView, and make
the AppFolders use it when figuring out the contained apps. Since reloading
the AllView results in AppFolders regenerated from scratch, the app info
list is ensured to be up-to-date for any later change within the AppFolder
(eg. through the GSettings key changing).
As the list was already filtered in the first place, we can also remove
the try{}catch() in AppFolder in order to discard desktop files with
invalid encoding.
Related: https://gitlab.gnome.org/GNOME/gnome-shell/issues/832
js/ui/appDisplay.js | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index c705a0d77..fed78475d 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -495,15 +495,21 @@ var AllView = new Lang.Class({
});
},
+ _getAppInfoList() {
+ return this._appInfoList;
+ },
+
_loadApps() {
- let apps = Gio.AppInfo.get_all().filter(appInfo => {
+ this._appInfoList = Gio.AppInfo.get_all().filter(appInfo => {
try {
let id = appInfo.get_id(); // catch invalid file encodings
} catch(e) {
return false;
}
return appInfo.should_show();
- }).map(app => app.get_id());
+ });
+
+ let apps = this._appInfoList.map(app => app.get_id());
let appSys = Shell.AppSystem.get_default();
@@ -1282,8 +1288,10 @@ var FolderIcon = new Lang.Class({
this._popup.popdown();
});
- this._folder.connect('changed', this._redisplay.bind(this));
- this._redisplay();
+ this._folder.connect('changed', () => {
+ this._redisplay(this._parentView._getAppInfoList());
+ });
+ this._redisplay(this._parentView._getAppInfoList());
},
getAppIds() {
@@ -1300,7 +1308,7 @@ var FolderIcon = new Lang.Class({
this.emit('name-changed');
},
- _redisplay() {
+ _redisplay(appInfoList) {
this._updateName();
this.view.removeAll();
@@ -1326,15 +1334,12 @@ var FolderIcon = new Lang.Class({
folderApps.forEach(addAppId);
let folderCategories = this._folder.get_strv('categories');
- Gio.AppInfo.get_all().forEach(appInfo => {
+ appInfoList.forEach(appInfo => {
let appCategories = _getCategories(appInfo);
if (!_listsIntersect(folderCategories, appCategories))
return;
- try {
- addAppId(appInfo.get_id()); // catch invalid file encodings
- } catch(e) {
- }
+ addAppId(appInfo.get_id());
});
this.actor.visible = this.view.getAllItems().length > 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]