[clang] [llvm] [Basic][NFC] Replace keyword StringSwitch with linear search (PR #236071)
Alexis Engelke via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 27 06:52:17 PDT 2026
================
@@ -147,6 +147,14 @@ template <typename T, unsigned NumStrs = 1> class EnumStrings {
return utohexstr(Value, true);
}
+ /// Return first entry whose name matches Str, or null.
+ const EnumString *fromString(StringRef Str, unsigned StrIdx = 0) const {
+ for (const auto &EnumItem : EnumValues)
----------------
aengelke wrote:
I don't think so (358 entries) and this is cold code. I added the TODO, because in the future we might have other uses of fromString() in longer lists where this might be useful. (I doubt we'll have a motivation for optimizing these functions in the foreseeable future, but you never know.)
https://github.com/llvm/llvm-project/pull/236071
More information about the cfe-commits
mailing list