Skip to content

Commit 379a1b2

Browse files
authored
Improve type-checking time of listTestsForSwiftPM (#365)
Type-checking of the chained return expression took over 10 secs.
1 parent 41fe485 commit 379a1b2

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Testing/Running/EntryPoint.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,14 @@ func listTestsForSwiftPM(_ tests: some Sequence<Test>) -> [String] {
107107
// Group tests by the name components of the tests' IDs. If the name
108108
// components of two tests' IDs are ambiguous, present their source locations
109109
// to disambiguate.
110-
return Dictionary(
110+
let initialGroups = Dictionary(
111111
grouping: tests.lazy.map(\.id),
112112
by: \.nameComponents
113113
).values.lazy
114114
.map { ($0, isAmbiguous: $0.count > 1) }
115-
.flatMap { testIDs, isAmbiguous in
115+
116+
// This operation is split to improve type-checking performance.
117+
return initialGroups.flatMap { testIDs, isAmbiguous in
116118
testIDs.lazy
117119
.map { testID in
118120
if !isAmbiguous, testID.sourceLocation != nil {

0 commit comments

Comments
 (0)