[clang] [TableGen] Avoid repeated map lookups (NFC) (PR #124448)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 25 21:57:49 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
This patch avoids repeated map lookups and constructions of temporary
std::string instances by switching to StringMap.
---
Full diff: https://github.com/llvm/llvm-project/pull/124448.diff
1 Files Affected:
- (modified) clang/utils/TableGen/MveEmitter.cpp (+3-3)
``````````diff
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));
}
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/124448
More information about the cfe-commits
mailing list