From 3548068c22f809e5bc64b83d2c3622018469256c Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 22 Jan 2013 19:05:17 +0000 Subject: [PATCH] Small code change to improve performance in my last patch, suggested by Argyrios. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173182 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Sema/Sema.h | 3 +++ lib/Sema/SemaExprObjC.cpp | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index a3402782a9..20d3db625a 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -575,6 +575,9 @@ public: /// \brief id type. QualType QIDNSCopying; + /// \brief will hold 'respondsToSelector:' + Selector RespondsToSelectorSel; + /// A flag to remember whether the implicit forms of operator new and delete /// have been declared. bool GlobalNewDeleteDeclared; diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp index 87da440191..7f0c832575 100644 --- a/lib/Sema/SemaExprObjC.cpp +++ b/lib/Sema/SemaExprObjC.cpp @@ -2485,8 +2485,12 @@ ExprResult Sema::ActOnInstanceMessage(Scope *S, MultiExprArg Args) { if (!Receiver) return ExprError(); - IdentifierInfo *SelectorId = &Context.Idents.get("respondsToSelector"); - if (Sel == Context.Selectors.getUnarySelector(SelectorId)) + + if (RespondsToSelectorSel.isNull()) { + IdentifierInfo *SelectorId = &Context.Idents.get("respondsToSelector"); + RespondsToSelectorSel = Context.Selectors.getUnarySelector(SelectorId); + } + if (Sel == RespondsToSelectorSel) RemoveSelectorFromWarningCache(*this, Args[0]); return BuildInstanceMessage(Receiver, Receiver->getType(),