Skip to content

Commit dec641e

Browse files
[Driver] Avoid repeated hash lookups (NFC) (#111468)
1 parent 416d1bd commit dec641e

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

clang/lib/Driver/MultilibBuilder.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ bool MultilibBuilder::isValid() const {
7474
llvm::StringMap<int> FlagSet;
7575
for (unsigned I = 0, N = Flags.size(); I != N; ++I) {
7676
StringRef Flag(Flags[I]);
77-
llvm::StringMap<int>::iterator SI = FlagSet.find(Flag.substr(1));
77+
auto [SI, Inserted] = FlagSet.try_emplace(Flag.substr(1), I);
7878

7979
assert(StringRef(Flag).front() == '-' || StringRef(Flag).front() == '!');
8080

81-
if (SI == FlagSet.end())
82-
FlagSet[Flag.substr(1)] = I;
83-
else if (Flags[I] != Flags[SI->getValue()])
81+
if (!Inserted && Flags[I] != Flags[SI->getValue()])
8482
return false;
8583
}
8684
return true;

0 commit comments

Comments
 (0)