[llvm] [BOLT] Avoid repeated hash lookups (NFC) (PR #111782)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 9 20:10:03 PDT 2024


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

None

>From d07fdaf0ba7f4f09d83f10ba62b9371ed4d8f72f Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 9 Oct 2024 06:49:53 -0700
Subject: [PATCH] [BOLT] Avoid repeated hash lookups (NFC)

---
 bolt/lib/Profile/YAMLProfileReader.cpp | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/bolt/lib/Profile/YAMLProfileReader.cpp b/bolt/lib/Profile/YAMLProfileReader.cpp
index 67ed32017667d6..fe0fcfdcd42f9b 100644
--- a/bolt/lib/Profile/YAMLProfileReader.cpp
+++ b/bolt/lib/Profile/YAMLProfileReader.cpp
@@ -643,11 +643,7 @@ size_t YAMLProfileReader::matchWithNameSimilarity(BinaryContext &BC) {
     // equal number of blocks.
     if (NamespaceToProfiledBFSizesIt->second.count(BF->size()) == 0)
       continue;
-    auto NamespaceToBFsIt = NamespaceToBFs.find(Namespace);
-    if (NamespaceToBFsIt == NamespaceToBFs.end())
-      NamespaceToBFs[Namespace] = {BF};
-    else
-      NamespaceToBFsIt->second.push_back(BF);
+    NamespaceToBFs[Namespace].push_back(BF);
   }
 
   // Iterates through all profiled functions and binary functions belonging to



More information about the llvm-commits mailing list