Skip to content

Commit 81ec7bd

Browse files
[Frontend] Avoid repeated hash lookups (NFC) (#107728)
1 parent f5aad24 commit 81ec7bd

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4340,17 +4340,13 @@ void RewriteModernObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
43404340
ValueDecl *VD = Exp->getDecl();
43414341
BlockDeclRefs.push_back(Exp);
43424342
if (!VD->hasAttr<BlocksAttr>()) {
4343-
if (!BlockByCopyDeclsPtrSet.count(VD)) {
4344-
BlockByCopyDeclsPtrSet.insert(VD);
4343+
if (BlockByCopyDeclsPtrSet.insert(VD).second)
43454344
BlockByCopyDecls.push_back(VD);
4346-
}
43474345
continue;
43484346
}
43494347

4350-
if (!BlockByRefDeclsPtrSet.count(VD)) {
4351-
BlockByRefDeclsPtrSet.insert(VD);
4348+
if (BlockByRefDeclsPtrSet.insert(VD).second)
43524349
BlockByRefDecls.push_back(VD);
4353-
}
43544350

43554351
// imported objects in the inner blocks not used in the outer
43564352
// blocks must be copied/disposed in the outer block as well.
@@ -5161,18 +5157,14 @@ void RewriteModernObjC::CollectBlockDeclRefInfo(BlockExpr *Exp) {
51615157
// Unique all "by copy" declarations.
51625158
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
51635159
if (!BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
5164-
if (!BlockByCopyDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
5165-
BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
5160+
if (BlockByCopyDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()).second)
51665161
BlockByCopyDecls.push_back(BlockDeclRefs[i]->getDecl());
5167-
}
51685162
}
51695163
// Unique all "by ref" declarations.
51705164
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)
51715165
if (BlockDeclRefs[i]->getDecl()->hasAttr<BlocksAttr>()) {
5172-
if (!BlockByRefDeclsPtrSet.count(BlockDeclRefs[i]->getDecl())) {
5173-
BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl());
5166+
if (BlockByRefDeclsPtrSet.insert(BlockDeclRefs[i]->getDecl()).second)
51745167
BlockByRefDecls.push_back(BlockDeclRefs[i]->getDecl());
5175-
}
51765168
}
51775169
// Find any imported blocks...they will need special attention.
51785170
for (unsigned i = 0; i < BlockDeclRefs.size(); i++)

0 commit comments

Comments
 (0)