r214293 - AST: Simplify some code
David Majnemer
david.majnemer at gmail.com
Wed Jul 30 01:42:33 PDT 2014
Author: majnemer
Date: Wed Jul 30 03:42:33 2014
New Revision: 214293
URL: http://llvm.org/viewvc/llvm-project?rev=214293&view=rev
Log:
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.
Modified:
cfe/trunk/lib/AST/ASTContext.cpp
Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=214293&r1=214292&r2=214293&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jul 30 03:42:33 2014
@@ -1432,12 +1432,13 @@ bool ASTContext::isAlignmentRequired(Qua
}
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;
}
More information about the cfe-commits
mailing list