Skip to content

Commit f60cc47

Browse files
committed
[clang][modules] NFC: Only sort interesting identifiers
In 9c25418 `ASTWriter` stopped writing identifiers that are not interesting. Taking it a bit further, we don't need to sort the whole identifier table, just the interesting identifiers. This reduces the size of sorted vector from ~10k (including lots of builtins) to 2 (`__VA_ARGS__` and `__VA_OPT__`) in a typical Xcode project, improving `clang-scan-deps` performance. Reviewed By: benlangmuir Differential Revision: https://reviews.llvm.org/D150494
1 parent 039b28e commit f60cc47

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3645,13 +3645,13 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
36453645
// file.
36463646
SmallVector<const IdentifierInfo *, 128> IIs;
36473647
for (const auto &ID : PP.getIdentifierTable())
3648-
IIs.push_back(ID.second);
3649-
// Sort the identifiers lexicographically before getting them references so
3648+
if (Trait.isInterestingNonMacroIdentifier(ID.second))
3649+
IIs.push_back(ID.second);
3650+
// Sort the identifiers lexicographically before getting the references so
36503651
// that their order is stable.
36513652
llvm::sort(IIs, llvm::deref<std::less<>>());
36523653
for (const IdentifierInfo *II : IIs)
3653-
if (Trait.isInterestingNonMacroIdentifier(II))
3654-
getIdentifierRef(II);
3654+
getIdentifierRef(II);
36553655

36563656
// Create the on-disk hash table representation. We only store offsets
36573657
// for identifiers that appear here for the first time.

0 commit comments

Comments
 (0)