From 3c5983b25f5c17a61d851a7e8cee7ec5fd43369b Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 30 Oct 2006 01:37:43 +0000 Subject: [PATCH] * src/Lru.py: Added least-recently-used module from the PyPE program * src/DisplayModels/_PeopleModel.py: use LRU module to speed up name displays svn: r7504 --- gramps2/ChangeLog | 4 ++++ gramps2/src/DisplayModels/_PeopleModel.py | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/gramps2/ChangeLog b/gramps2/ChangeLog index edc5274b6..2d0be4f73 100644 --- a/gramps2/ChangeLog +++ b/gramps2/ChangeLog @@ -1,4 +1,8 @@ 2006-10-29 Don Allingham + * src/Lru.py: Added least-recently-used module from + the PyPE program + * src/DisplayModels/_PeopleModel.py: use LRU module to speed up + name displays * configure.in: post 2.2.1 release update * src/GrampsDb/_ReadXML.py: handle broken events * help/C/gramps.xml: fix diff --git a/gramps2/src/DisplayModels/_PeopleModel.py b/gramps2/src/DisplayModels/_PeopleModel.py index 0d54b5980..57719a042 100644 --- a/gramps2/src/DisplayModels/_PeopleModel.py +++ b/gramps2/src/DisplayModels/_PeopleModel.py @@ -66,6 +66,7 @@ import ToolTips import GrampsLocale import Config from Filters import SearchFilter +from lru import LRU #------------------------------------------------------------------------- # @@ -158,6 +159,7 @@ class PeopleModel(gtk.GenericTreeModel): self.iter2path = {} self.path2iter = {} self.sname_sub = {} + if filter_info: if filter_info[0] == PeopleModel.GENERIC: data_filter = filter_info[1] @@ -242,6 +244,7 @@ class PeopleModel(gtk.GenericTreeModel): Calculates the new path to node values for the model. """ + self.lru = LRU(500) if dfilter: self.dfilter = dfilter self.temp_iter2path = {} @@ -258,6 +261,7 @@ class PeopleModel(gtk.GenericTreeModel): self.build_sub_entry(name) def clear_cache(self): + self.lru = LRU(500) self.prev_handle = None def build_sub_entry(self, name): @@ -411,7 +415,12 @@ class PeopleModel(gtk.GenericTreeModel): return spouses_names def column_name(self, data, node): - return NameDisplay.displayer.raw_sorted_name(data[PeopleModel._NAME_COL]) + try: + name = self.lru[node] + except: + name = NameDisplay.displayer.raw_sorted_name(data[PeopleModel._NAME_COL]) + self.lru[node] = name + return name def column_id(self, data, node): return data[PeopleModel._ID_COL]