From 2e4afca5e3baefe15499bf3c5ac7635f466a93ae Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 22 Sep 2026 06:49:26 +0200 Subject: [PATCH] App.get_project_refs(): Use a set for deduplication get_project_refs() deduplicates the walk results by scanning the result list for each appended element, so the cost grows quadratically with the number of projects, which is noticeable when walking a dev tree of 320 projects. Track the already-seen projects in a set, and append an element only when it is new. The resulting list is unchanged, and the membership test is O(1) instead of O(n). Signed-off-by: Jan Lindemann Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1 --- src/python/jw/pkg/App.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/python/jw/pkg/App.py b/src/python/jw/pkg/App.py index dabb97ef..8a67dc3e 100644 --- a/src/python/jw/pkg/App.py +++ b/src/python/jw/pkg/App.py @@ -590,6 +590,7 @@ class App(Base): if isinstance(keys, str): keys = [keys] ret: list[str] = [] + seen: set[str] = set() for key in keys: visited: set[str] = set() for name in projects: @@ -597,9 +598,9 @@ class App(Base): self.walk_project_deps( rr, visited, name, sections, key, add_self, scope, names_only ) - # TODO: this looks like a performance hogger for m in rr: - if m not in ret: + if m not in seen: + seen.add(m) ret.append(m) return ret