App.get_project_refs(): Use a set for deduplication
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m30s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m35s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 5m7s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m36s
CI / Packaging test (push) Successful in 0s

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 <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v0.86.1
This commit is contained in:
Jan Lindemann 2026-09-22 06:49:26 +02:00
commit 2e4afca5e3
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -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