[clang] a44ee8e - [TableGen] Use heterogenous lookups with std::map (NFC) (#115633)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 10 07:24:30 PST 2024
Author: Kazu Hirata
Date: 2024-11-10T07:24:27-08:00
New Revision: a44ee8ec1c87be76e147d97f3be90a7e8630421b
URL: https://github.com/llvm/llvm-project/commit/a44ee8ec1c87be76e147d97f3be90a7e8630421b
DIFF: https://github.com/llvm/llvm-project/commit/a44ee8ec1c87be76e147d97f3be90a7e8630421b.diff
LOG: [TableGen] Use heterogenous lookups with std::map (NFC) (#115633)
Heterogenous lookups allow us to call find with StringRef, avoiding a
temporary heap allocation of std::string.
Added:
Modified:
clang/utils/TableGen/NeonEmitter.cpp
Removed:
################################################################################
diff --git a/clang/utils/TableGen/NeonEmitter.cpp b/clang/utils/TableGen/NeonEmitter.cpp
index c6d82646b40de2..7081e5c9ae93e8 100644
--- a/clang/utils/TableGen/NeonEmitter.cpp
+++ b/clang/utils/TableGen/NeonEmitter.cpp
@@ -578,7 +578,7 @@ class Intrinsic {
class NeonEmitter {
const RecordKeeper &Records;
DenseMap<const Record *, ClassKind> ClassMap;
- std::map<std::string, std::deque<Intrinsic>> IntrinsicMap;
+ std::map<std::string, std::deque<Intrinsic>, std::less<>> IntrinsicMap;
unsigned UniqueNumber;
void createIntrinsic(const Record *R, SmallVectorImpl<Intrinsic *> &Out);
@@ -1937,9 +1937,9 @@ void Intrinsic::indexBody() {
Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types,
std::optional<std::string> MangledName) {
// First, look up the name in the intrinsic map.
- assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
+ assert_with_loc(IntrinsicMap.find(Name) != IntrinsicMap.end(),
("Intrinsic '" + Name + "' not found!").str());
- auto &V = IntrinsicMap.find(Name.str())->second;
+ auto &V = IntrinsicMap.find(Name)->second;
std::vector<Intrinsic *> GoodVec;
// Create a string to print if we end up failing.
More information about the cfe-commits
mailing list