From 304855c10d9ebe8dbb87af40bfed391e548504c1 Mon Sep 17 00:00:00 2001 From: Bryan Schumaker Date: Fri, 20 Aug 2010 08:27:12 -0400 Subject: [PATCH] Use gtk.ListStore.insert The append function of a ListStore is extremely slow. Now I use the ListStore insert function, and manually track the size of the list myself. --- libsaria/collection/collection.py | 1 - libsaria/collection/tree.py | 1 + ocarina/collection.py | 5 ++--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libsaria/collection/collection.py b/libsaria/collection/collection.py index 22c8d907..c04b41d7 100644 --- a/libsaria/collection/collection.py +++ b/libsaria/collection/collection.py @@ -11,7 +11,6 @@ ins_tree = None class Collection: def __init__(self): self.tree = None - #self.load() def __iter__(self): if not self.tree: diff --git a/libsaria/collection/tree.py b/libsaria/collection/tree.py index 5d5f10c4..c38df1db 100644 --- a/libsaria/collection/tree.py +++ b/libsaria/collection/tree.py @@ -28,6 +28,7 @@ class Tree(dict): def walk(self): keys = self.keys() keys.sort() + keys.reverse() get_item = self.__getitem__ for key in keys: for track in get_item(key).walk(): diff --git a/ocarina/collection.py b/ocarina/collection.py index f0e0e133..2634fcbe 100644 --- a/ocarina/collection.py +++ b/ocarina/collection.py @@ -21,11 +21,10 @@ class Collection(gtk.ScrolledWindow): def populate(self, func): self.list.freeze() - append = self.list.append + insert = self.list.list.insert for track in func(): - #print track get = track.__getitem__ - append([get("id"), + insert(0, [get("id"), get("title"), get("length"), get("artist"),