[clang] [Rewrite] Avoid repeated hash lookups (NFC) (PR #109605)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 22 21:08:22 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/109605
None
>From 50ce6d0114f8abd4b5580d2c277525eebdf25874 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 22 Sep 2024 08:05:27 -0700
Subject: [PATCH] [Rewrite] Avoid repeated hash lookups (NFC)
---
clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 180a0125023ee7..ac5baf72a65c90 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -4358,21 +4358,21 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
for (unsigned i = 0; i < InnerBlockDeclRefs.size(); i++) {
DeclRefExpr *Exp = InnerBlockDeclRefs[i];
ValueDecl *VD = Exp->getDecl();
- if (!VD->hasAttr<BlocksAttr>() && !BlockByCopyDeclsPtrSet.count(VD)) {
+ if (!VD->hasAttr<BlocksAttr>() &&
+ BlockByCopyDeclsPtrSet.insert(VD).second) {
// We need to save the copied-in variables in nested
// blocks because it is needed at the end for some of the API
// generations. See SynthesizeBlockLiterals routine.
InnerDeclRefs.push_back(Exp);
countOfInnerDecls++;
BlockDeclRefs.push_back(Exp);
- BlockByCopyDeclsPtrSet.insert(VD);
BlockByCopyDecls.push_back(VD);
}
- if (VD->hasAttr<BlocksAttr>() && !BlockByRefDeclsPtrSet.count(VD)) {
+ if (VD->hasAttr<BlocksAttr>() &&
+ BlockByRefDeclsPtrSet.insert(VD).second) {
InnerDeclRefs.push_back(Exp);
countOfInnerDecls++;
BlockDeclRefs.push_back(Exp);
- BlockByRefDeclsPtrSet.insert(VD);
BlockByRefDecls.push_back(VD);
}
}
More information about the cfe-commits
mailing list