From e6343623e5edf5032f4ff5842f12e08731f55242 Mon Sep 17 00:00:00 2001 From: rogue-spectre Date: Sun, 23 Oct 2016 18:28:21 +0200 Subject: [PATCH 1/2] optimize find added and removed applications --- .../mintMenu/plugins/applications.py | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 2a927ef..9404c91 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -1667,30 +1667,22 @@ class pluginclass( object ): if not self.applicationList: addedApplications = newApplicationList else: + applicationListPaths = sorted([ item["entry"].get_desktop_file_path() for item in self.applicationList ]) for item in newApplicationList: - found = False - for item2 in self.applicationList: - if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path(): - found = True - break - if not found: + if not (item["entry"].get_desktop_file_path() in applicationListPaths): addedApplications.append(item) - + key = 0 + newApplicationListPaths = sorted([ item["entry"].get_desktop_file_path() for item in newApplicationList ]) for item in self.applicationList: - found = False - for item2 in newApplicationList: - if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path(): - found = True - break - if not found: - removedApplications.append(key) + if not ( item["entry"].get_desktop_file_path() in newApplicationListPaths ): + removeApplications.append(key) else: # don't increment the key if this item is going to be removed # because when it is removed the index of all later items is # going to be decreased key += 1 - + for key in removedApplications: self.applicationList[key]["button"].destroy() del self.applicationList[key] From cd4375e4d598540c07bebe24cebd894c9f8550be Mon Sep 17 00:00:00 2001 From: rogue-spectre Date: Sat, 5 Nov 2016 18:20:43 +0100 Subject: [PATCH 2/2] remove spaces --- usr/lib/linuxmint/mintMenu/plugins/applications.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr/lib/linuxmint/mintMenu/plugins/applications.py b/usr/lib/linuxmint/mintMenu/plugins/applications.py index 9404c91..d907e75 100755 --- a/usr/lib/linuxmint/mintMenu/plugins/applications.py +++ b/usr/lib/linuxmint/mintMenu/plugins/applications.py @@ -1671,7 +1671,7 @@ class pluginclass( object ): for item in newApplicationList: if not (item["entry"].get_desktop_file_path() in applicationListPaths): addedApplications.append(item) - + key = 0 newApplicationListPaths = sorted([ item["entry"].get_desktop_file_path() for item in newApplicationList ]) for item in self.applicationList: @@ -1682,7 +1682,7 @@ class pluginclass( object ): # because when it is removed the index of all later items is # going to be decreased key += 1 - + for key in removedApplications: self.applicationList[key]["button"].destroy() del self.applicationList[key]