From b2b0efd5f3325a109560095442705648a44d646b Mon Sep 17 00:00:00 2001 From: Bastien Orivel Date: Fri, 17 Oct 2025 15:41:52 +0200 Subject: [PATCH] Use `links_and_reverse_links_dict` in `replace_tasks` In b7134975846a0bc2266213bc64cd4e2b0c953067 we added a function to get both `links_dict` and `reverse_links_dict` in one go, avoiding iterating over the graph twice to build those. That function also benefits from being cached. I'm not expecting a big change in performance here but we might as well. --- src/taskgraph/optimize/base.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/taskgraph/optimize/base.py b/src/taskgraph/optimize/base.py index 3d2776a87..c291d4a8f 100644 --- a/src/taskgraph/optimize/base.py +++ b/src/taskgraph/optimize/base.py @@ -297,8 +297,9 @@ def replace_tasks( opt_counts = defaultdict(int) replaced = set() - dependents_of = target_task_graph.graph.reverse_links_dict() - dependencies_of = target_task_graph.graph.links_dict() + dependencies_of, dependents_of = ( + target_task_graph.graph.links_and_reverse_links_dict() + ) for label in target_task_graph.graph.visit_postorder(): logger.debug(f"replace_tasks: {label}")