Skip to content

Commit a44ee8e

Browse files
[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.
1 parent 5b19ed8 commit a44ee8e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

clang/utils/TableGen/NeonEmitter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ class Intrinsic {
578578
class NeonEmitter {
579579
const RecordKeeper &Records;
580580
DenseMap<const Record *, ClassKind> ClassMap;
581-
std::map<std::string, std::deque<Intrinsic>> IntrinsicMap;
581+
std::map<std::string, std::deque<Intrinsic>, std::less<>> IntrinsicMap;
582582
unsigned UniqueNumber;
583583

584584
void createIntrinsic(const Record *R, SmallVectorImpl<Intrinsic *> &Out);
@@ -1937,9 +1937,9 @@ void Intrinsic::indexBody() {
19371937
Intrinsic &NeonEmitter::getIntrinsic(StringRef Name, ArrayRef<Type> Types,
19381938
std::optional<std::string> MangledName) {
19391939
// First, look up the name in the intrinsic map.
1940-
assert_with_loc(IntrinsicMap.find(Name.str()) != IntrinsicMap.end(),
1940+
assert_with_loc(IntrinsicMap.find(Name) != IntrinsicMap.end(),
19411941
("Intrinsic '" + Name + "' not found!").str());
1942-
auto &V = IntrinsicMap.find(Name.str())->second;
1942+
auto &V = IntrinsicMap.find(Name)->second;
19431943
std::vector<Intrinsic *> GoodVec;
19441944

19451945
// Create a string to print if we end up failing.

0 commit comments

Comments
 (0)