[clang] [TableGen] Avoid repeated map lookups (NFC) (PR #124448)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 25 21:57:18 PST 2025
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/124448
This patch avoids repeated map lookups and constructions of temporary
std::string instances by switching to StringMap.
>From 2273e9e518fa5625a40298a970dfd3ad1c3f27db Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 25 Jan 2025 16:07:33 -0800
Subject: [PATCH] [TableGen] Avoid repeated map lookups (NFC)
This patch avoids repeated map lookups and constructions of temporary
std::string instances by switching to StringMap.
---
clang/utils/TableGen/MveEmitter.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index 8ebd0bb800feff..7f298d1cbd4376 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -60,6 +60,7 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/raw_ostream.h"
@@ -1955,18 +1956,17 @@ void MveEmitter::EmitBuiltinDef(raw_ostream &OS) {
<< ", \"\", \"n\")\n";
}
- std::set<std::string> ShortNamesSeen;
+ StringSet<> ShortNamesSeen;
for (const auto &kv : ACLEIntrinsics) {
const ACLEIntrinsic &Int = *kv.second;
if (Int.polymorphic()) {
StringRef Name = Int.shortName();
- if (ShortNamesSeen.find(std::string(Name)) == ShortNamesSeen.end()) {
+ if (ShortNamesSeen.insert(Name).second) {
OS << "BUILTIN(__builtin_arm_mve_" << Name << ", \"vi.\", \"nt";
if (Int.nonEvaluating())
OS << "u"; // indicate that this builtin doesn't evaluate its args
OS << "\")\n";
- ShortNamesSeen.insert(std::string(Name));
}
}
}
More information about the cfe-commits
mailing list