diff options
author | Harmen Stoppels <me@harmenstoppels.nl> | 2024-07-02 16:41:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-02 16:41:29 +0200 |
commit | 5b4edb9499921747a3c36963e301d5e1981481c7 (patch) | |
tree | 552679cf1430742be1384478793132797f40c7a5 | |
parent | a6e60939226e4d8271a478cc8f5f93796b6346bf (diff) | |
download | spack-5b4edb9499921747a3c36963e301d5e1981481c7.tar.gz spack-5b4edb9499921747a3c36963e301d5e1981481c7.tar.bz2 spack-5b4edb9499921747a3c36963e301d5e1981481c7.tar.xz spack-5b4edb9499921747a3c36963e301d5e1981481c7.zip |
queue -> stack (#45002)
-rw-r--r-- | lib/spack/spack/util/libc.py | 8 | ||||
-rw-r--r-- | lib/spack/spack/util/spack_yaml.py | 8 |
2 files changed, 8 insertions, 8 deletions
diff --git a/lib/spack/spack/util/libc.py b/lib/spack/spack/util/libc.py index bcfbbec646..402bf6f244 100644 --- a/lib/spack/spack/util/libc.py +++ b/lib/spack/spack/util/libc.py @@ -128,9 +128,9 @@ def startfile_prefix(prefix: str, compatible_with: str = sys.executable) -> Opti except Exception: accept = lambda path: True - queue = [(0, prefix)] - while queue: - depth, path = queue.pop() + stack = [(0, prefix)] + while stack: + depth, path = stack.pop() try: iterator = os.scandir(path) except OSError: @@ -140,7 +140,7 @@ def startfile_prefix(prefix: str, compatible_with: str = sys.executable) -> Opti try: if entry.is_dir(follow_symlinks=True): if depth < 2: - queue.append((depth + 1, entry.path)) + stack.append((depth + 1, entry.path)) elif entry.name == "crt1.o" and accept(entry.path): return path except Exception: diff --git a/lib/spack/spack/util/spack_yaml.py b/lib/spack/spack/util/spack_yaml.py index 04f88faafa..b3326d2959 100644 --- a/lib/spack/spack/util/spack_yaml.py +++ b/lib/spack/spack/util/spack_yaml.py @@ -497,10 +497,10 @@ def anchorify(data: Union[dict, list], identifier: Callable[[Any], str] = repr) """Replace identical dict/list branches in tree with references to earlier instances. The YAML serializer generate anchors for them, resulting in small yaml files.""" anchors: Dict[str, Union[dict, list]] = {} - queue: List[Union[dict, list]] = [data] + stack: List[Union[dict, list]] = [data] - while queue: - item = queue.pop() + while stack: + item = stack.pop() for key, value in item.items() if isinstance(item, dict) else enumerate(item): if not isinstance(value, (dict, list)): @@ -511,7 +511,7 @@ def anchorify(data: Union[dict, list], identifier: Callable[[Any], str] = repr) if anchor is None: anchors[id] = value - queue.append(value) + stack.append(value) else: item[key] = anchor # replace with reference |