Benjamin Schubert pushed to branch bschubert/set-as-set at BuildStream / buildstream
Commits:
-
261d6ae2
by Benjamin Schubert at 2019-02-15T11:24:05Z
3 changed files:
Changes:
... | ... | @@ -284,17 +284,17 @@ class Loader(): |
284 | 284 |
def _check_circular_deps(self, element, check_elements=None, validated=None, sequence=None):
|
285 | 285 |
|
286 | 286 |
if check_elements is None:
|
287 |
- check_elements = {}
|
|
287 |
+ check_elements = set()
|
|
288 | 288 |
if validated is None:
|
289 |
- validated = {}
|
|
289 |
+ validated = set()
|
|
290 | 290 |
if sequence is None:
|
291 | 291 |
sequence = []
|
292 | 292 |
|
293 | 293 |
# Skip already validated branches
|
294 |
- if validated.get(element) is not None:
|
|
294 |
+ if element in validated:
|
|
295 | 295 |
return
|
296 | 296 |
|
297 |
- if check_elements.get(element) is not None:
|
|
297 |
+ if element in check_elements:
|
|
298 | 298 |
# Create `chain`, the loop of element dependencies from this
|
299 | 299 |
# element back to itself, by trimming everything before this
|
300 | 300 |
# element from the sequence under consideration.
|
... | ... | @@ -306,15 +306,15 @@ class Loader(): |
306 | 306 |
.format(element.full_name, " -> ".join(chain)))
|
307 | 307 |
|
308 | 308 |
# Push / Check each dependency / Pop
|
309 |
- check_elements[element] = True
|
|
309 |
+ check_elements.add(element)
|
|
310 | 310 |
sequence.append(element.full_name)
|
311 | 311 |
for dep in element.dependencies:
|
312 | 312 |
dep.element._loader._check_circular_deps(dep.element, check_elements, validated, sequence)
|
313 |
- del check_elements[element]
|
|
313 |
+ check_elements.remove(element)
|
|
314 | 314 |
sequence.pop()
|
315 | 315 |
|
316 | 316 |
# Eliminate duplicate paths
|
317 |
- validated[element] = True
|
|
317 |
+ validated.add(element)
|
|
318 | 318 |
|
319 | 319 |
# _sort_dependencies():
|
320 | 320 |
#
|
... | ... | @@ -26,7 +26,7 @@ import datetime |
26 | 26 |
import time
|
27 | 27 |
|
28 | 28 |
# Track what profile topics are active
|
29 |
-active_topics = {}
|
|
29 |
+active_topics = set()
|
|
30 | 30 |
active_profiles = {}
|
31 | 31 |
initialized = False
|
32 | 32 |
|
... | ... | @@ -144,14 +144,10 @@ def profile_init(): |
144 | 144 |
if setting:
|
145 | 145 |
topics = setting.split(':')
|
146 | 146 |
for topic in topics:
|
147 |
- active_topics[topic] = True
|
|
147 |
+ active_topics.add(topic)
|
|
148 | 148 |
initialized = True
|
149 | 149 |
|
150 | 150 |
|
151 | 151 |
def profile_enabled(topic):
|
152 | 152 |
profile_init()
|
153 |
- if active_topics.get(topic):
|
|
154 |
- return True
|
|
155 |
- if active_topics.get(Topics.ALL):
|
|
156 |
- return True
|
|
157 |
- return False
|
|
153 |
+ return topic in active_topics or Topics.ALL in active_topics
|
... | ... | @@ -154,7 +154,7 @@ class TarSource(DownloadableFileSource): |
154 | 154 |
# directory paths for the archived files.
|
155 | 155 |
def _list_tar_paths(self, tar):
|
156 | 156 |
|
157 |
- visited = {}
|
|
157 |
+ visited = set()
|
|
158 | 158 |
for member in tar.getmembers():
|
159 | 159 |
|
160 | 160 |
# Remove any possible leading './', offer more consistent behavior
|
... | ... | @@ -170,7 +170,7 @@ class TarSource(DownloadableFileSource): |
170 | 170 |
for i in range(len(components) - 1):
|
171 | 171 |
dir_component = '/'.join([components[j] for j in range(i + 1)])
|
172 | 172 |
if dir_component not in visited:
|
173 |
- visited[dir_component] = True
|
|
173 |
+ visited.add(dir_component)
|
|
174 | 174 |
try:
|
175 | 175 |
# Dont yield directory members which actually do
|
176 | 176 |
# exist in the archive
|