AST: Simplify some code
Iterator invalidation issues already force us to do one lookup and one
insert.
Don't use the particular bit-pattern of the 'Align' field to determine
whether or not we have already inserted into the TypeInfo DenseMap;
instead ask for an iterator to the TypeInfo entry.
llvm-svn: 214293
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index a9d606c..220b61d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1432,12 +1432,13 @@
}
TypeInfo ASTContext::getTypeInfo(const Type *T) const {
- TypeInfo TI = MemoizedTypeInfo[T];
- if (!TI.Align) {
- // This call can invalidate MemoizedTypeInfo[T], so we need a second lookup.
- TI = getTypeInfoImpl(T);
- MemoizedTypeInfo[T] = TI;
- }
+ TypeInfoMap::iterator I = MemoizedTypeInfo.find(T);
+ if (I != MemoizedTypeInfo.end())
+ return I->second;
+
+ // This call can invalidate MemoizedTypeInfo[T], so we need a second lookup.
+ TypeInfo TI = getTypeInfoImpl(T);
+ MemoizedTypeInfo[T] = TI;
return TI;
}