From: David Majnemer Date: Wed, 30 Jul 2014 08:42:33 +0000 (+0000) Subject: AST: Simplify some code X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cdcaa88b183095b3192f431460226791247f442e;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214293 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index a9d606c60d..220b61dbe0 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1432,12 +1432,13 @@ bool ASTContext::isAlignmentRequired(QualType T) const { } 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; }