Skip to content

Commit 23a80f8

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 (cherry picked from commit f60cc47)
1 parent 830d66d commit 23a80f8

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
@@ -3677,13 +3677,13 @@ void ASTWriter::WriteIdentifierTable(Preprocessor &PP,
36773677
// file.
36783678
SmallVector<const IdentifierInfo *, 128> IIs;
36793679
for (const auto &ID : PP.getIdentifierTable())
3680-
IIs.push_back(ID.second);
3681-
// Sort the identifiers lexicographically before getting them references so
3680+
if (Trait.isInterestingNonMacroIdentifier(ID.second))
3681+
IIs.push_back(ID.second);
3682+
// Sort the identifiers lexicographically before getting the references so
36823683
// that their order is stable.
36833684
llvm::sort(IIs, llvm::deref<std::less<>>());
36843685
for (const IdentifierInfo *II : IIs)
3685-
if (Trait.isInterestingNonMacroIdentifier(II))
3686-
getIdentifierRef(II);
3686+
getIdentifierRef(II);
36873687

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

0 commit comments

Comments
 (0)