diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-07-03 12:39:14 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-07-03 13:10:16 +0000 |
commit | 0b6897771f6c7deb5562f48ae5bc118c57d04870 (patch) | |
tree | 1f7104b5d1bff3e4b669465d8efaeaee51fa64bc /morphlib | |
parent | e3e84967d2b0d19825d278c1b73bee8fb48d83ba (diff) | |
download | morph-0b6897771f6c7deb5562f48ae5bc118c57d04870.tar.gz |
BuildCommand: make get_recursive_deps iterative
This is less code and can't blow the stack.
Diffstat (limited to 'morphlib')
-rwxr-xr-x | morphlib/app.py | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/morphlib/app.py b/morphlib/app.py index 196b9874..7c6d852c 100755 --- a/morphlib/app.py +++ b/morphlib/app.py @@ -223,14 +223,13 @@ class BuildCommand(object): def get_recursive_deps(self, artifact): done = set() - self._get_recursive_deps(artifact, done) + todo = set((artifact,)) + while todo: + for a in todo.pop().dependencies: + if a not in done: + done.add(a) + todo.add(a) return done - - def _get_recursive_deps(self, artifact, done): - for a in artifact.dependencies: - if a not in done: - done.add(a) - self._get_recursive_deps(a, done) def get_sources(self, artifact): '''Update the local git repository cache with the sources.''' |