[llvm] [XRay] Use DenseMap::{operator[], try_emplace} (NFC) (PR #107178)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 23:56:15 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];
----------------
nikic wrote:
nit: Use `return Edges[I];` instead? It doesn't look like we actually use the variable.
https://github.com/llvm/llvm-project/pull/107178
More information about the llvm-commits
mailing list