diff options
author | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-12-14 15:12:29 +0000 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-12-14 15:12:38 +0000 |
commit | 07f241a0aa4d485a8fe16c3d6a1d2ccf632c785b (patch) | |
tree | 444e24bdbb1f29219a5ca7cc0420ec1f7171e39b /morphlib | |
parent | 35f9111d9497160c44a5e4fa2b8a1964e68d0fd5 (diff) | |
parent | 301b7937b5c39e3121ba528f414fe53efb8086cd (diff) | |
download | morph-07f241a0aa4d485a8fe16c3d6a1d2ccf632c785b.tar.gz |
Merge branch 'jannispohlmann/cache-resolved-refs-and-morphologies'
Reviewed-by: Lars Wirzenius <lars.wirzenius@codethink.co.uk>
Diffstat (limited to 'morphlib')
-rwxr-xr-x | morphlib/app.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 0a11c716..d154f8b9 100755 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -292,15 +292,29 @@ class Morph(cliapp.Application): self) queue = collections.deque(triplets) updated_repos = set() + resolved_refs = {} + resolved_morphologies = {} while queue: reponame, ref, filename = queue.popleft() update_repo = update and reponame not in updated_repos - absref, tree = self.resolve_ref(lrc, rrc, reponame, ref, - update_repo) + + # Resolve the (repo, ref) reference, cache result. + reference = (reponame, ref) + if not reference in resolved_refs: + resolved_refs[reference] = self.resolve_ref( + lrc, rrc, reponame, ref, update_repo) + absref, tree = resolved_refs[reference] + updated_repos.add(reponame) - morphology = morph_factory.get_morphology( - reponame, absref, filename) + + # Fetch the (repo, ref, filename) morphology, cache result. + reference = (reponame, absref, filename) + if not reference in resolved_morphologies: + resolved_morphologies[reference] = \ + morph_factory.get_morphology(reponame, absref, filename) + morphology = resolved_morphologies[reference] + visit(reponame, ref, filename, absref, tree, morphology) if morphology['kind'] == 'system': queue.extend((s['repo'], s['ref'], '%s.morph' % s['morph']) |