diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2009-11-27 11:21:09 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2009-11-27 11:21:09 +0100 |
commit | f28a2041f707986b65dbcdb4bb363bb39e4b3f77 (patch) | |
tree | b37c8ff6b932716bd5b8befdc1469bc175facb65 /lib/git/objects | |
parent | accfe361443b3cdb8ea43ca0ccb8fbb2fa202e12 (diff) | |
download | gitpython-f28a2041f707986b65dbcdb4bb363bb39e4b3f77.tar.gz |
improved performance of item traversal, its nearly as fast as it was with the first very pure implementation
Diffstat (limited to 'lib/git/objects')
-rw-r--r-- | lib/git/objects/utils.py | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/lib/git/objects/utils.py b/lib/git/objects/utils.py index 27caa083..18968c0f 100644 --- a/lib/git/objects/utils.py +++ b/lib/git/objects/utils.py @@ -113,18 +113,15 @@ class Traversable(object): ``branch_first`` if True, items will be returned branch first, otherwise depth first - ``visit_once`` - if True, items will only be returned once, although they might be encountered - several times. Loops are prevented that way. - ``ignore_self`` if True, self will be ignored and automatically pruned from the result. Otherwise it will be the first item to be returned""" - visited = set() stack = Deque() stack.append( ( 0 ,self ) ) # self is always depth level 0 def addToStack( stack, lst, branch_first, dpth ): + if not lst: + return if branch_first: stack.extendleft( ( dpth , item ) for item in lst ) else: @@ -135,12 +132,6 @@ class Traversable(object): while stack: d, item = stack.pop() # depth of item, item - if item in visited: - continue - - if visit_once: - visited.add( item ) - if prune( item ): continue |