Skip to content
Snippets Groups Projects
Commit 3bbb90e7 authored by Benjamin Schubert's avatar Benjamin Schubert
Browse files

Use sets when checking for existence of an element

parent 8b34e356
No related branches found
No related tags found
1 merge request!1154Use sets when checking for existence of an element
Pipeline #47684316 passed
......@@ -284,17 +284,17 @@ class Loader():
def _check_circular_deps(self, element, check_elements=None, validated=None, sequence=None):
if check_elements is None:
check_elements = {}
check_elements = set()
if validated is None:
validated = {}
validated = set()
if sequence is None:
sequence = []
# Skip already validated branches
if validated.get(element) is not None:
if element in validated:
return
if check_elements.get(element) is not None:
if element in check_elements:
# Create `chain`, the loop of element dependencies from this
# element back to itself, by trimming everything before this
# element from the sequence under consideration.
......@@ -306,15 +306,15 @@ class Loader():
.format(element.full_name, " -> ".join(chain)))
# Push / Check each dependency / Pop
check_elements[element] = True
check_elements.add(element)
sequence.append(element.full_name)
for dep in element.dependencies:
dep.element._loader._check_circular_deps(dep.element, check_elements, validated, sequence)
del check_elements[element]
check_elements.remove(element)
sequence.pop()
# Eliminate duplicate paths
validated[element] = True
validated.add(element)
# _sort_dependencies():
#
......
......@@ -26,7 +26,7 @@ import datetime
import time
# Track what profile topics are active
active_topics = {}
active_topics = set()
active_profiles = {}
initialized = False
......@@ -144,14 +144,10 @@ def profile_init():
if setting:
topics = setting.split(':')
for topic in topics:
active_topics[topic] = True
active_topics.add(topic)
initialized = True
def profile_enabled(topic):
profile_init()
if active_topics.get(topic):
return True
if active_topics.get(Topics.ALL):
return True
return False
return topic in active_topics or Topics.ALL in active_topics
......@@ -154,7 +154,7 @@ class TarSource(DownloadableFileSource):
# directory paths for the archived files.
def _list_tar_paths(self, tar):
visited = {}
visited = set()
for member in tar.getmembers():
# Remove any possible leading './', offer more consistent behavior
......@@ -170,7 +170,7 @@ class TarSource(DownloadableFileSource):
for i in range(len(components) - 1):
dir_component = '/'.join([components[j] for j in range(i + 1)])
if dir_component not in visited:
visited[dir_component] = True
visited.add(dir_component)
try:
# Dont yield directory members which actually do
# exist in the archive
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment