Author: Kazu Hirata Date: 2024-09-08T00:08:06-07:00 New Revision: 81ec7bd4183439ba824045b92f00fdebb10ff224
URL: https://github.com/llvm/llvm-project/commit/81ec7bd4183439ba824045b92f00fdebb10ff224 DIFF: https://github.com/llvm/llvm-project/commit/81ec7bd4183439ba824045b92f00fdebb10ff224.diff LOG: [Frontend] Avoid repeated hash lookups (NFC) (#107728) Added: Modified: clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp Removed: ################################################################################ diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp index f618c536b5f3c6..31ec86e2e4f096 100644 --- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp +++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp @@ -4340,17 +4340,13 @@ void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart, ValueDecl *VD = Exp->getDecl(); BlockDeclRefs.push_back(Exp); if (!VD->hasAttr<BlocksAttr>()) { - if (!BlockByCopyDeclsPtrSet.count(VD)) { - BlockByCopyDeclsPtrSet.insert(VD); + if (BlockByCopyDeclsPtrSet.insert(VD).second) BlockByCopyDecls.push_back(VD); - } continue; } - if (!BlockByRefDeclsPtrSet.count(VD)) { - BlockByRefDeclsPtrSet.insert(VD); + if (BlockByRefDeclsPtrSet.insert(VD).second) BlockByRefDecls.push_back(VD); - } // imported objects in the inner blocks not used in the outer // blocks must be copied/disposed in the outer block as well. @@ -5161,18 +5157,14 @@ void RewriteModernObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) { // Unique all "by copy" declarations. for (unsigned i = 0; i < BlockDeclRefs.size(); i++) if (!BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) { - if (!BlockByCopyDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) { - BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()); + if (BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()).second) BlockByCopyDecls.push_back(BlockDeclRefs[i]->getDecl()); - } } // Unique all "by ref" declarations. for (unsigned i = 0; i < BlockDeclRefs.size(); i++) if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) { - if (!BlockByRefDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) { - BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()); + if (BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()).second) BlockByRefDecls.push_back(BlockDeclRefs[i]->getDecl()); - } } // Find any imported blocks...they will need special attention. for (unsigned i = 0; i < BlockDeclRefs.size(); i++) _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits