[clang] 1884ffc - [TableGen] Use heterogenous lookups with std::map (NFC) (#115994)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 13 06:41:38 PST 2024
Author: Kazu Hirata
Date: 2024-11-13T06:41:33-08:00
New Revision: 1884ffc41c20b1e08b30eef4e8ebbcc54543a139
URL: https://github.com/llvm/llvm-project/commit/1884ffc41c20b1e08b30eef4e8ebbcc54543a139
DIFF: https://github.com/llvm/llvm-project/commit/1884ffc41c20b1e08b30eef4e8ebbcc54543a139.diff
LOG: [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.
Added:
Modified:
clang/utils/TableGen/MveEmitter.cpp
Removed:
################################################################################
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 51e570944b49b6..5ae894d8e0718c 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -471,7 +471,7 @@ class Result {
public:
virtual ~Result() = default;
- using Scope = std::map<std::string, Ptr>;
+ using Scope = std::map<std::string, Ptr, std::less<>>;
virtual void genCode(raw_ostream &OS, CodeGenParamAllocator &) const = 0;
virtual bool hasIntegerConstantValue() const { return false; }
virtual uint32_t integerConstantValue() const { return 0; }
@@ -1278,7 +1278,7 @@ Result::Ptr EmitterBase::getCodeForDagArg(const DagInit *D, unsigned ArgNum,
if (!isa<UnsetInit>(Arg))
PrintFatalError(
"dag operator argument should not have both a value and a name");
- auto it = Scope.find(std::string(Name));
+ auto it = Scope.find(Name);
if (it == Scope.end())
PrintFatalError("unrecognized variable name '" + Name + "'");
return it->second;
More information about the cfe-commits
mailing list