[clang] [Driver] Avoid repeated map lookups (NFC) (PR #122625)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 18:22:23 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-driver
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/122625.diff
1 Files Affected:
- (modified) clang/lib/Driver/Driver.cpp (+2-2)
``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4d9492ea08f647..10df730744b089 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2534,8 +2534,8 @@ enum {
static unsigned PrintActions1(const Compilation &C, Action *A,
std::map<Action *, unsigned> &Ids,
Twine Indent = {}, int Kind = TopLevelAction) {
- if (Ids.count(A)) // A was already visited.
- return Ids[A];
+ if (auto It = Ids.find(A); It != Ids.end()) // A was already visited.
+ return It->second;
std::string str;
llvm::raw_string_ostream os(str);
``````````
</details>
https://github.com/llvm/llvm-project/pull/122625
More information about the cfe-commits
mailing list