comparison mercurial/templater.py @ 10849:12ffc5ce1291

templater: cache self.defaults.get
author Matt Mackall <mpm@selenic.com>
date Mon, 05 Apr 2010 15:25:08 -0500
parents 01346cea5485
children a63391e26284
comparison
equal deleted inserted replaced
10848:01346cea5485 10849:12ffc5ce1291
71 yield str(item) 71 yield str(item)
72 72
73 def _parse(self, tmpl): 73 def _parse(self, tmpl):
74 '''preparse a template''' 74 '''preparse a template'''
75 75
76 defget = self._defaults.get
76 def getter(mapping, key): 77 def getter(mapping, key):
77 v = mapping.get(key) 78 v = mapping.get(key)
78 if v is None: 79 if v is None:
79 v = self.defaults.get(key, '') 80 v = defget(key, '')
80 if hasattr(v, '__call__'): 81 if hasattr(v, '__call__'):
81 v = v(**mapping) 82 v = v(**mapping)
82 return v 83 return v
83 84
84 def raw(mapping, x): 85 def raw(mapping, x):