Cache the maker instance for three heavy users (Container.get_visible_terminals, Window.get_visible_terminals and Window.set_rough_geometry_hints)

This commit is contained in:
Stephen Boddy 2011-02-17 02:57:30 +01:00
parent 03791c753b
commit b3bee59c9d
2 changed files with 9 additions and 3 deletions

View File

@ -195,7 +195,9 @@ the %s will also close all terminals within it.') % (reqtype, reqtype))
def get_visible_terminals(self): def get_visible_terminals(self):
"""Walk the widget tree to find all of the visible terminals. That is, """Walk the widget tree to find all of the visible terminals. That is,
any terminals which are not hidden in another Notebook pane""" any terminals which are not hidden in another Notebook pane"""
maker = Factory() if not hasattr(self, 'cached_maker'):
self.cached_maker = Factory()
maker = self.cached_maker
terminals = {} terminals = {}
for child in self.get_offspring(): for child in self.get_offspring():

View File

@ -480,7 +480,9 @@ class Window(Container, gtk.Window):
"""Walk down the widget tree to find all of the visible terminals. """Walk down the widget tree to find all of the visible terminals.
Mostly using Container::get_visible_terminals()""" Mostly using Container::get_visible_terminals()"""
terminals = {} terminals = {}
maker = Factory() if not hasattr(self, 'cached_maker'):
self.cached_maker = Factory()
maker = self.cached_maker
child = self.get_child() child = self.get_child()
if not child: if not child:
@ -511,7 +513,9 @@ class Window(Container, gtk.Window):
def set_rough_geometry_hints(self): def set_rough_geometry_hints(self):
"""Walk all the terminals along the top and left edges to fake up how """Walk all the terminals along the top and left edges to fake up how
many columns/rows we sort of have""" many columns/rows we sort of have"""
maker = Factory() if not hasattr(self, 'cached_maker'):
self.cached_maker = Factory()
maker = self.cached_maker
if maker.isinstance(self.get_child(), 'Notebook'): if maker.isinstance(self.get_child(), 'Notebook'):
dbg("We don't currently support geometry hinting with tabs") dbg("We don't currently support geometry hinting with tabs")
return return