From 5b4edb9499921747a3c36963e301d5e1981481c7 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Tue, 2 Jul 2024 16:41:29 +0200 Subject: queue -> stack (#45002) --- lib/spack/spack/util/libc.py | 8 ++++---- 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 -- cgit v1.2.3-70-g09d2