[clang] [TableGen] Use heterogenous lookups with std::map (NFC) (PR #115994)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 21:25:43 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
---
Full diff: https://github.com/llvm/llvm-project/pull/115994.diff
1 Files Affected:
- (modified) clang/utils/TableGen/MveEmitter.cpp (+2-2)
``````````diff
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/115994
More information about the cfe-commits
mailing list