[llvm] 323b3a7 - [Passes] Avoid repeated hash lookups (NFC) (#110790)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 06:54:07 PDT 2024


Author: Kazu Hirata
Date: 2024-10-02T06:54:03-07:00
New Revision: 323b3a75826f05b931157095ff559e88b4d370d5

URL: https://github.com/llvm/llvm-project/commit/323b3a75826f05b931157095ff559e88b4d370d5
DIFF: https://github.com/llvm/llvm-project/commit/323b3a75826f05b931157095ff559e88b4d370d5.diff

LOG: [Passes] Avoid repeated hash lookups (NFC) (#110790)

Added: 
    

Modified: 
    llvm/lib/Passes/StandardInstrumentations.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Passes/StandardInstrumentations.cpp b/llvm/lib/Passes/StandardInstrumentations.cpp
index c960afcf6e9736..c37af27615dd91 100644
--- a/llvm/lib/Passes/StandardInstrumentations.cpp
+++ b/llvm/lib/Passes/StandardInstrumentations.cpp
@@ -2040,13 +2040,14 @@ DotCfgDiff::DotCfgDiff(StringRef Title, const FuncDataT<DCData> &Before,
     StringRef Colour = E.second;
 
     // Look for an edge from Source to Sink
-    if (EdgeLabels.count(SourceSink) == 0)
-      EdgeLabels.insert({SourceSink, colourize(Value.str(), Colour)});
+    auto [It, Inserted] = EdgeLabels.try_emplace(SourceSink);
+    if (Inserted)
+      It->getValue() = colourize(Value.str(), Colour);
     else {
-      StringRef V = EdgeLabels.find(SourceSink)->getValue();
+      StringRef V = It->getValue();
       std::string NV = colourize(V.str() + " " + Value.str(), Colour);
       Colour = CommonColour;
-      EdgeLabels[SourceSink] = NV;
+      It->getValue() = NV;
     }
     SourceNode.addEdge(SinkNode, Value, Colour);
   }


        


More information about the llvm-commits mailing list