templater: clarify engine caching
authorMatt Mackall <mpm@selenic.com>
Wed, 22 Dec 2010 13:16:03 -0600
changeset 13187 e3b87fb34d00
parent 13186 fda7ae939344
child 13189 f5be619663f9
templater: clarify engine caching
mercurial/templater.py
--- a/mercurial/templater.py	Wed Dec 22 13:16:00 2010 -0600
+++ b/mercurial/templater.py	Wed Dec 22 13:16:03 2010 -0600
@@ -282,7 +282,7 @@
         self.filters.update(filters)
         self.defaults = defaults
         self.minchunk, self.maxchunk = minchunk, maxchunk
-        self.engines = {}
+        self.ecache = {}
 
         if not mapfile:
             return
@@ -322,10 +322,10 @@
 
     def __call__(self, t, **mapping):
         ttype = t in self.map and self.map[t][0] or 'default'
-        proc = self.engines.get(ttype)
-        if proc is None:
-            proc = engines[ttype](self.load, self.filters, self.defaults)
-            self.engines[ttype] = proc
+        if ttype not in self.ecache:
+            self.ecache[ttype] = engines[ttype](self.load,
+                                                 self.filters, self.defaults)
+        proc = self.ecache[ttype]
 
         stream = proc.process(t, mapping)
         if self.minchunk: