[clang] [Frontend] Avoid repeated hash lookups (NFC) (PR #108738)

Kazu Hirata via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 15 00:07:15 PDT 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/108738

None

>From 21dcd68cb908289a77470e8c8878452d25b99200 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 13 Sep 2024 21:29:51 -0700
Subject: [PATCH] [Frontend] Avoid repeated hash lookups (NFC)

---
 clang/lib/Frontend/Rewrite/RewriteObjC.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index 9db6ddbf0b8908..fd5e8dc5298950 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -4111,9 +4111,8 @@ void RewriteObjC::RewriteBlockPointerDecl(NamedDecl *ND) {
 std::string RewriteObjC::SynthesizeByrefCopyDestroyHelper(VarDecl *VD,
                                                           int flag) {
   std::string S;
-  if (CopyDestroyCache.count(flag))
+  if (!CopyDestroyCache.insert(flag).second)
     return S;
-  CopyDestroyCache.insert(flag);
   S = "static void __Block_byref_id_object_copy_";
   S += utostr(flag);
   S += "(void *dst, void *src) {\n";



More information about the cfe-commits mailing list