Skip to content

Commit c7cf6d2

Browse files
committed
Reuse the traversal key path in TestFilter's precomputed filter
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.)
1 parent 88efc08 commit c7cf6d2

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

Sources/Testing/Running/Configuration.TestFilter.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,18 +283,18 @@ extension Configuration.TestFilter.Operation {
283283
case let .precomputed(selection, membership):
284284
switch membership {
285285
case .including:
286-
return testGraph.mapValues { _, item in
286+
return testGraph.mapValues { keyPath, item in
287287
guard let item else {
288288
return nil
289289
}
290-
return selection.contains(item.test) ? item : nil
290+
return selection.contains(keyPath) ? item : nil
291291
}
292292
case .excluding:
293-
return testGraph.mapValues { _, item in
293+
return testGraph.mapValues { keyPath, item in
294294
guard let item else {
295295
return nil
296296
}
297-
return !selection.contains(item.test, inferAncestors: false) ? item : nil
297+
return !selection.contains(keyPath, inferAncestors: false) ? item : nil
298298
}
299299
}
300300
case let .function(function, membership):

0 commit comments

Comments
 (0)