From d97e62fa270a70f8da08dcf3136864dc1c3b5cb2 Mon Sep 17 00:00:00 2001 From: Benny Malengier Date: Mon, 29 Jun 2009 20:46:00 +0000 Subject: [PATCH] optimization suggested by Gerald to avoid append svn: r12734 --- src/gui/views/treemodels/flatbasemodel.py | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/gui/views/treemodels/flatbasemodel.py b/src/gui/views/treemodels/flatbasemodel.py index 85442a09e..4e49637a8 100644 --- a/src/gui/views/treemodels/flatbasemodel.py +++ b/src/gui/views/treemodels/flatbasemodel.py @@ -468,23 +468,15 @@ class FlatBaseModel(gtk.GenericTreeModel): """ Return the (sort_key, handle) list of all data that can maximally 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 = [] - - with self.gen_cursor() as cursor: # use cursor as a context manager + # use cursor as a context manager + with self.gen_cursor() as cursor: #loop over database and store the sort field, and the handle - for key, data in cursor: - ## as per locale doc, use strxfrm for frequent compare. - ## 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 + return sorted( (locale.strxfrm(self.sort_func(data)), key) + for key, data in cursor ) def _rebuild_search(self, ignore=None): """ function called when view must be build, given a search text