https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/115682
Heterogenous lookups allow us to call find with StringRef, avoiding a temporary heap allocation of std::string. >From 2c8d9a85e3e959f544d3e1bf474376acf31648ca Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sun, 10 Nov 2024 07:30:30 -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/NeonEmitter.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp index 7081e5c9ae93e8..68ca31e27e0a41 100644 --- a/clang/utils/TableGen/NeonEmitter.cpp +++ b/clang/utils/TableGen/NeonEmitter.cpp @@ -340,7 +340,7 @@ class Intrinsic { /// The index of the key type passed to CGBuiltin.cpp for polymorphic calls. int PolymorphicKeyType; /// The local variables defined. - std::map<std::string, Variable> Variables; + std::map<std::string, Variable, std::less<>> Variables; /// NeededEarly - set if any other intrinsic depends on this intrinsic. bool NeededEarly; /// UseMacro - set if we should implement using a macro or unset for a @@ -1548,8 +1548,8 @@ Intrinsic::DagEmitter::emitDagCast(const DagInit *DI, bool IsBitCast) { // 5. The value "H" or "D" to half or double the bitwidth. // 6. The value "8" to convert to 8-bit (signed) integer lanes. if (!DI->getArgNameStr(ArgIdx).empty()) { - assert_with_loc(Intr.Variables.find(std::string( - DI->getArgNameStr(ArgIdx))) != Intr.Variables.end(), + assert_with_loc(Intr.Variables.find(DI->getArgNameStr(ArgIdx)) != + Intr.Variables.end(), "Variable not found"); castToType = Intr.Variables[std::string(DI->getArgNameStr(ArgIdx))].getType(); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits