optimization suggested by Gerald to avoid append
svn: r12734
This commit is contained in:
parent
57dc74b965
commit
d97e62fa27
@ -468,23 +468,15 @@ class FlatBaseModel(gtk.GenericTreeModel):
|
|||||||
"""
|
"""
|
||||||
Return the (sort_key, handle) list of all data that can maximally
|
Return the (sort_key, handle) list of all data that can maximally
|
||||||
be shown.
|
be shown.
|
||||||
This list is sorted ascending (via localized string sort)
|
This list is sorted ascending, via localized string sort. strxfrm
|
||||||
|
is used, which is apparently broken in Win ?? --> they should fix
|
||||||
|
base lib, we need strxfrm
|
||||||
"""
|
"""
|
||||||
sort_data = []
|
# use cursor as a context manager
|
||||||
|
with self.gen_cursor() as cursor:
|
||||||
with self.gen_cursor() as cursor: # use cursor as a context manager
|
|
||||||
#loop over database and store the sort field, and the handle
|
#loop over database and store the sort field, and the handle
|
||||||
for key, data in cursor:
|
return sorted( (locale.strxfrm(self.sort_func(data)), key)
|
||||||
## as per locale doc, use strxfrm for frequent compare.
|
for key, data in cursor )
|
||||||
## apparently broken in Win --> they should fix base lib !!
|
|
||||||
#add to sort_data in such a way that bisect module can be
|
|
||||||
# used on the result later on.
|
|
||||||
sort_data.append((locale.strxfrm(self.sort_func(data)),
|
|
||||||
key))
|
|
||||||
#bisect.insort_left(sort_data,
|
|
||||||
# (locale.strxfrm(self.sort_func(data)), key))
|
|
||||||
sort_data.sort()
|
|
||||||
return sort_data
|
|
||||||
|
|
||||||
def _rebuild_search(self, ignore=None):
|
def _rebuild_search(self, ignore=None):
|
||||||
""" function called when view must be build, given a search text
|
""" function called when view must be build, given a search text
|
||||||
|
Loading…
x
Reference in New Issue
Block a user