[llvm] [NFC][TableGen] Minor code cleanup in SearchableTableEmitter (PR #147856)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 9 22:43:41 PDT 2025


================
@@ -232,67 +235,74 @@ int64_t SearchableTableEmitter::getNumericKey(const SearchIndex &Index,
 /// key of \p Index.
 bool SearchableTableEmitter::compareBy(const Record *LHS, const Record *RHS,
                                        const SearchIndex &Index) {
-  for (const auto &Field : Index.Fields) {
-    const Init *LHSI = LHS->getValueInit(Field.Name);
-    const Init *RHSI = RHS->getValueInit(Field.Name);
+  // Compare two values and return:
+  // true if LHS < RHS
+  // false if  LHS > RHS
+  // std::nullopt if LHS == RHS
+  auto CmpLTValue = [](const auto &LHS,
+                       const auto &RHS) -> std::optional<bool> {
+    if (LHS < RHS)
----------------
topperc wrote:

Does this do 2 comparisons for StringRefs?

https://github.com/llvm/llvm-project/pull/147856


More information about the llvm-commits mailing list