From 0c75b45911baa52d6a496f689c401102cd6a0b4a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 20 Feb 2011 20:09:22 -0500 Subject: - use the _uri_cache for adjust_uri(), as this is called each time there's a namespace or include --- mako/lookup.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mako/lookup.py b/mako/lookup.py index d3763d6..3ca289a 100644 --- a/mako/lookup.py +++ b/mako/lookup.py @@ -221,13 +221,18 @@ class TemplateLookup(TemplateCollection): def adjust_uri(self, uri, relativeto): """adjust the given uri based on the given relative uri.""" + key = (uri, relativeto) + if key in self._uri_cache: + return self._uri_cache[key] + if uri[0] != '/': if relativeto is not None: - return posixpath.join(posixpath.dirname(relativeto), uri) + v = self._uri_cache[key] = posixpath.join(posixpath.dirname(relativeto), uri) else: - return '/' + uri + v = self._uri_cache[key] = '/' + uri else: - return uri + v = self._uri_cache[key] = uri + return v def filename_to_uri(self, filename): -- cgit v1.2.1