[clang] [TableGen] Use heterogenous lookups with std::map (NFC) (PR #115633)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Nov 9 22:16:00 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/115633.diff
1 Files Affected:
- (modified) clang/utils/TableGen/NeonEmitter.cpp (+3-3)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/115633
More information about the cfe-commits
mailing list