Skip to content

[XRay] Simplify code with DenseMap::operator[] (NFC) #111786

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@kazutakahirata kazutakahirata requested a review from nikic October 10, 2024 03:12
@llvmbot llvmbot added the xray label Oct 10, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 10, 2024

@llvm/pr-subscribers-xray

Author: Kazu Hirata (kazutakahirata)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/111786.diff

1 Files Affected:

  • (modified) llvm/lib/XRay/BlockIndexer.cpp (+3-6)
diff --git a/llvm/lib/XRay/BlockIndexer.cpp b/llvm/lib/XRay/BlockIndexer.cpp
index a99a6815f0d16b..f4ba0eb5bda9cf 100644
--- a/llvm/lib/XRay/BlockIndexer.cpp
+++ b/llvm/lib/XRay/BlockIndexer.cpp
@@ -80,12 +80,9 @@ Error BlockIndexer::visit(FunctionRecord &R) {
 }
 
 Error BlockIndexer::flush() {
-  Index::iterator It;
-  std::tie(It, std::ignore) =
-      Indices.insert({{CurrentBlock.ProcessID, CurrentBlock.ThreadID}, {}});
-  It->second.push_back({CurrentBlock.ProcessID, CurrentBlock.ThreadID,
-                        CurrentBlock.WallclockTime,
-                        std::move(CurrentBlock.Records)});
+  Indices[{CurrentBlock.ProcessID, CurrentBlock.ThreadID}].push_back(
+      {CurrentBlock.ProcessID, CurrentBlock.ThreadID,
+       CurrentBlock.WallclockTime, std::move(CurrentBlock.Records)});
   CurrentBlock.ProcessID = 0;
   CurrentBlock.ThreadID = 0;
   CurrentBlock.Records = {};

@kazutakahirata kazutakahirata changed the title [XRay] Avoid repeated hash lookups (NFC) [XRay] Simplify code with DenseMap::operator[] (NFC) Oct 10, 2024
Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kazutakahirata kazutakahirata merged commit 35bbfbc into llvm:main Oct 10, 2024
10 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_operator_sq_br_XRay branch October 10, 2024 15:18
DanielCChen pushed a commit to DanielCChen/llvm-project that referenced this pull request Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants