Skip to content

Commit 1884ffc

Browse files
[TableGen] Use heterogenous lookups with std::map (NFC) (#115994)
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string.
1 parent 2560505 commit 1884ffc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

clang/utils/TableGen/MveEmitter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ class Result {
471471

472472
public:
473473
virtual ~Result() = default;
474-
using Scope = std::map<std::string, Ptr>;
474+
using Scope = std::map<std::string, Ptr, std::less<>>;
475475
virtual void genCode(raw_ostream &OS, CodeGenParamAllocator &) const = 0;
476476
virtual bool hasIntegerConstantValue() const { return false; }
477477
virtual uint32_t integerConstantValue() const { return 0; }
@@ -1278,7 +1278,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(const DagInit *D, unsigned ArgNum,
12781278
if (!isa<UnsetInit>(Arg))
12791279
PrintFatalError(
12801280
"dag operator argument should not have both a value and a name");
1281-
auto it = Scope.find(std::string(Name));
1281+
auto it = Scope.find(Name);
12821282
if (it == Scope.end())
12831283
PrintFatalError("unrecognized variable name '" + Name + "'");
12841284
return it->second;

0 commit comments

Comments
 (0)