optimize find added and removed applications
This commit is contained in:
parent
eafbd9d7ef
commit
e6343623e5
@ -1667,30 +1667,22 @@ class pluginclass( object ):
|
|||||||
if not self.applicationList:
|
if not self.applicationList:
|
||||||
addedApplications = newApplicationList
|
addedApplications = newApplicationList
|
||||||
else:
|
else:
|
||||||
|
applicationListPaths = sorted([ item["entry"].get_desktop_file_path() for item in self.applicationList ])
|
||||||
for item in newApplicationList:
|
for item in newApplicationList:
|
||||||
found = False
|
if not (item["entry"].get_desktop_file_path() in applicationListPaths):
|
||||||
for item2 in self.applicationList:
|
|
||||||
if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path():
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
addedApplications.append(item)
|
addedApplications.append(item)
|
||||||
|
|
||||||
key = 0
|
key = 0
|
||||||
|
newApplicationListPaths = sorted([ item["entry"].get_desktop_file_path() for item in newApplicationList ])
|
||||||
for item in self.applicationList:
|
for item in self.applicationList:
|
||||||
found = False
|
if not ( item["entry"].get_desktop_file_path() in newApplicationListPaths ):
|
||||||
for item2 in newApplicationList:
|
removeApplications.append(key)
|
||||||
if item["entry"].get_desktop_file_path() == item2["entry"].get_desktop_file_path():
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
if not found:
|
|
||||||
removedApplications.append(key)
|
|
||||||
else:
|
else:
|
||||||
# don't increment the key if this item is going to be removed
|
# 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
|
# because when it is removed the index of all later items is
|
||||||
# going to be decreased
|
# going to be decreased
|
||||||
key += 1
|
key += 1
|
||||||
|
|
||||||
for key in removedApplications:
|
for key in removedApplications:
|
||||||
self.applicationList[key]["button"].destroy()
|
self.applicationList[key]["button"].destroy()
|
||||||
del self.applicationList[key]
|
del self.applicationList[key]
|
||||||
|
Loading…
Reference in New Issue
Block a user