From c3ef53c430a7684311f14916510befb7a4fed22c Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Fri, 17 Oct 2014 11:44:44 +0000 Subject: [PATCH] Optimize Type::isStructureOrClassType() by reusing RT->getDecl(). RecordType->getDecl() which maps to TagType::getDecl() is not a simple accessor but a loop on redecls in getInterestingTagDecl. isStructureOrClassType() was calling getDecl() three times performing three times the work actually required. It is optimized by calling RT->getDecl() once and reusing the result three times. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@220033 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/AST/Type.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index ad8a1ed670..726db9229f 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -378,9 +378,10 @@ bool Type::isInterfaceType() const { return false; } bool Type::isStructureOrClassType() const { - if (const RecordType *RT = getAs()) - return RT->getDecl()->isStruct() || RT->getDecl()->isClass() || - RT->getDecl()->isInterface(); + if (const RecordType *RT = getAs()) { + RecordDecl *RD = RT->getDecl(); + return RD->isStruct() || RD->isClass() || RD->isInterface(); + } return false; } bool Type::isVoidPointerType() const { -- 2.40.0