Skip to content

Commit 4fb2a22

Browse files
committed
[Index] Write stdlib records in alphabetical order
The order for writing records of the stdlib currently depends on `StringMap` iteration (in a slightly roundabout manner). Sort these alphabetically instead.
1 parent 1219459 commit 4fb2a22

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/Index/IndexRecord.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,15 @@ class StdlibGroupsIndexRecordingConsumer : public IndexDataConsumer {
233233
}
234234

235235
void finish() override {
236-
for (auto &pair : TrackerByGroup) {
237-
StringRef groupName = pair.first();
238-
SymbolTracker &tracker = *pair.second;
236+
SmallVector<std::pair<StringRef, SymbolTracker &>, 0> SortedGroups;
237+
for (auto &entry : TrackerByGroup) {
238+
SortedGroups.emplace_back(entry.first(), *entry.second);
239+
}
240+
llvm::sort(SortedGroups, llvm::less_first());
241+
242+
for (auto &pair : SortedGroups) {
243+
StringRef groupName = pair.first;
244+
SymbolTracker &tracker = pair.second;
239245
bool cont = onFinish(groupName, tracker);
240246
if (!cont)
241247
break;

test/Index/Store/unit-one-file-multi-file-invocation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
// CHECK: [[SWIFT]]
2020
// CHECK: DEPEND START
21-
// CHECK: Record | system | Swift.String | [[MODULE]] | {{.+}}.swiftinterface_String-{{.*}}
2221
// CHECK: Record | system | Swift.Math.Floating | [[MODULE]] | {{.+}}.swiftinterface_Math_Floating-{{.*}}
22+
// CHECK: Record | system | Swift.String | [[MODULE]] | {{.+}}.swiftinterface_String-{{.*}}
2323
// CHECK: DEPEND END
2424

2525
func test1() {

0 commit comments

Comments
 (0)