summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-02-20 20:09:22 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-02-20 20:09:22 -0500
commit0c75b45911baa52d6a496f689c401102cd6a0b4a (patch)
tree0ce7cbff577fe8079e72b4468e8ee3000c3572fb
parent6cc1d50c14f121d341a3d25fcb0681eafea46a2c (diff)
downloadmako-0c75b45911baa52d6a496f689c401102cd6a0b4a.tar.gz
- use the _uri_cache for adjust_uri(), as this is called each time
there's a namespace or include
-rw-r--r--mako/lookup.py11
1 files 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):