Mercurial > hg
diff mercurial/templater.py @ 38439:256581484c7f
templater: resurrect cache of engine instance
The engine-level cache was effectively disabled at 48289eafb37d "templater:
drop extension point of engine classes (API)" by mistake, which made template
rendering quite slow.
Spotted by Martin von Zweigbergk.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Thu, 21 Jun 2018 22:27:30 +0900 |
parents | f79237942dec |
children | 3813c6b7337c |
line wrap: on
line diff
--- a/mercurial/templater.py Thu Jun 21 22:23:43 2018 +0900 +++ b/mercurial/templater.py Thu Jun 21 22:27:30 2018 +0900 @@ -872,6 +872,8 @@ self.defaults = defaults self._resources = resources self._loader = loader(cache, aliases) + self._proc = engine(self._loader.load, self._filters, self.defaults, + self._resources) self._minchunk, self._maxchunk = minchunk, maxchunk @classmethod @@ -923,8 +925,7 @@ def generate(self, t, mapping): """Return a generator that renders the specified named template and yields chunks""" - proc = engine(self.load, self._filters, self.defaults, self._resources) - stream = proc.process(t, mapping) + stream = self._proc.process(t, mapping) if self._minchunk: stream = util.increasingchunks(stream, min=self._minchunk, max=self._maxchunk)