[llvm] [XRay] Use DenseMap::{operator[], try_emplace} (NFC) (PR #107178)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 02:02:30 PDT 2024


================
@@ -378,20 +378,18 @@ class Graph {
 
   /// Looks up the vertex with identifier I, if it does not exist it default
   /// constructs it.
-  VertexAttribute &operator[](const VertexIdentifier &I) {
-    return Vertices.FindAndConstruct(I).second;
-  }
+  VertexAttribute &operator[](const VertexIdentifier &I) { return Vertices[I]; }
 
   /// Looks up the edge with identifier I, if it does not exist it default
   /// constructs it, if it's endpoints do not exist it also default constructs
   /// them.
   EdgeAttribute &operator[](const EdgeIdentifier &I) {
-    auto &P = Edges.FindAndConstruct(I);
-    Vertices.FindAndConstruct(I.first);
-    Vertices.FindAndConstruct(I.second);
+    auto &Attr = Edges[I];
----------------
kazutakahirata wrote:

Fixed in the latest iteration.  Thanks!

https://github.com/llvm/llvm-project/pull/107178


More information about the llvm-commits mailing list