| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -113,18 +113,15 @@ def traverse( self, predicate = lambda i: True, | |||
| 113 | 113 | ``branch_first`` | |
| 114 | 114 | if True, items will be returned branch first, otherwise depth first | |
| 115 | 115 | ||
| 116 | - ``visit_once`` | ||
| 117 | - if True, items will only be returned once, although they might be encountered | ||
| 118 | - several times. Loops are prevented that way. | ||
| 119 | - | ||
| 120 | 116 | ``ignore_self`` | |
| 121 | 117 | if True, self will be ignored and automatically pruned from | |
| 122 | 118 | the result. Otherwise it will be the first item to be returned""" | |
| 123 | - visited = set() | ||
| 124 | 119 | stack = Deque() | |
| 125 | 120 | stack.append( ( 0 ,self ) ) # self is always depth level 0 | |
| 126 | 121 | ||
| 127 | 122 | def addToStack( stack, lst, branch_first, dpth ): | |
| 123 | + if not lst: | ||
| 124 | + return | ||
| 128 | 125 | if branch_first: | |
| 129 | 126 | stack.extendleft( ( dpth , item ) for item in lst ) | |
| 130 | 127 | else: | |
@@ -135,12 +132,6 @@ def addToStack( stack, lst, branch_first, dpth ): | |||
| 135 | 132 | while stack: | |
| 136 | 133 | d, item = stack.pop() # depth of item, item | |
| 137 | 134 | ||
| 138 | - if item in visited: | ||
| 139 | - continue | ||
| 140 | - | ||
| 141 | - if visit_once: | ||
| 142 | - visited.add( item ) | ||
| 143 | - | ||
| 144 | 135 | if prune( item ): | |
| 145 | 136 | continue | |
| 146 | 137 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments