https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/115994
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. >From 9fb5006cd20c4ecb3a5aaec2bdd355089a5dabc9 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Tue, 12 Nov 2024 10:17:42 -0800 Subject: [PATCH] [TableGen] Use heterogenous lookups with std::map (NFC) Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. --- clang/utils/TableGen/MveEmitter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits