[clang] [Driver] Avoid repeated hash lookups (NFC) (PR #111468)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 7 19:45:16 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/111468
None
>From 9bc29851603347edbc4324ccbdb4fef47a1c2626 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Mon, 7 Oct 2024 07:06:51 -0700
Subject: [PATCH] [Driver] Avoid repeated hash lookups (NFC)
---
clang/lib/Driver/MultilibBuilder.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/clang/lib/Driver/MultilibBuilder.cpp b/clang/lib/Driver/MultilibBuilder.cpp
index 15adf501778093..4b365a164c4586 100644
--- a/clang/lib/Driver/MultilibBuilder.cpp
+++ b/clang/lib/Driver/MultilibBuilder.cpp
@@ -74,13 +74,11 @@ bool MultilibBuilder::isValid() const {
llvm::StringMap<int> FlagSet;
for (unsigned I = 0, N = Flags.size(); I != N; ++I) {
StringRef Flag(Flags[I]);
- llvm::StringMap<int>::iterator SI = FlagSet.find(Flag.substr(1));
+ auto [SI, Inserted] = FlagSet.try_emplace(Flag.substr(1), I);
assert(StringRef(Flag).front() == '-' || StringRef(Flag).front() == '!');
- if (SI == FlagSet.end())
- FlagSet[Flag.substr(1)] = I;
- else if (Flags[I] != Flags[SI->getValue()])
+ if (!Inserted && Flags[I] != Flags[SI->getValue()])
return false;
}
return true;
More information about the cfe-commits
mailing list