[clang] [Driver] Avoid repeated map lookups (NFC) (PR #122625)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 18:21:50 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/122625
None
>From b9a6a99e421170fbc1fb8c6641a83d21dfa0076c Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 11 Jan 2025 17:53:36 -0800
Subject: [PATCH] [Driver] Avoid repeated map lookups (NFC)
---
clang/lib/Driver/Driver.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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);
More information about the cfe-commits
mailing list