From c7cf6d2e66b82e0114d52ed486574fe41a42be3f Mon Sep 17 00:00:00 2001 From: inju2403 <56947879+inju2403@users.noreply.github.com> Date: Fri, 5 Jun 2026 20:12:08 +0900 Subject: [PATCH] Reuse the traversal key path in TestFilter's precomputed filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TestFilter's precomputed filter receives each node's key path from the graph traversal but discards it and reconstructs the same value via `item.test.id.keyPathRepresentation` — re-allocating a [String] and re-formatting the source location to a string per node. Since the graph is built by inserting each test at `test.id.keyPathRepresentation`, the node's key path *is* that value, so use it directly. Simpler, and removes a per-node allocation + string format from the filtering path. (~3.7x on the isolated per-node membership check; absolute per-run cost is sub-ms — this is a readability cleanup first.) --- Sources/Testing/Running/Configuration.TestFilter.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/Testing/Running/Configuration.TestFilter.swift b/Sources/Testing/Running/Configuration.TestFilter.swift index 06bdb15df..17b423729 100644 --- a/Sources/Testing/Running/Configuration.TestFilter.swift +++ b/Sources/Testing/Running/Configuration.TestFilter.swift @@ -283,18 +283,18 @@ extension Configuration.TestFilter.Operation { case let .precomputed(selection, membership): switch membership { case .including: - return testGraph.mapValues { _, item in + return testGraph.mapValues { keyPath, item in guard let item else { return nil } - return selection.contains(item.test) ? item : nil + return selection.contains(keyPath) ? item : nil } case .excluding: - return testGraph.mapValues { _, item in + return testGraph.mapValues { keyPath, item in guard let item else { return nil } - return !selection.contains(item.test, inferAncestors: false) ? item : nil + return !selection.contains(keyPath, inferAncestors: false) ? item : nil } } case let .function(function, membership):