Skip to content

Commit 8bdc312

Browse files
[Index] Avoid repeated hash lookups (NFC) (#127300)
1 parent 77b309d commit 8bdc312

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

clang/lib/Index/USRGeneration.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -859,16 +859,12 @@ void USRGenerator::VisitType(QualType T) {
859859
}
860860

861861
// If we have already seen this (non-built-in) type, use a substitution
862-
// encoding.
863-
llvm::DenseMap<const Type *, unsigned>::iterator Substitution
864-
= TypeSubstitutions.find(T.getTypePtr());
865-
if (Substitution != TypeSubstitutions.end()) {
862+
// encoding. Otherwise, record this as a substitution.
863+
auto [Substitution, Inserted] =
864+
TypeSubstitutions.try_emplace(T.getTypePtr(), TypeSubstitutions.size());
865+
if (!Inserted) {
866866
Out << 'S' << Substitution->second << '_';
867867
return;
868-
} else {
869-
// Record this as a substitution.
870-
unsigned Number = TypeSubstitutions.size();
871-
TypeSubstitutions[T.getTypePtr()] = Number;
872868
}
873869

874870
if (const PointerType *PT = T->getAs<PointerType>()) {

0 commit comments

Comments
 (0)