[llvm] [ADT] Simplify StringSet::contains (NFC) (PR #157325)

via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 7 00:00:07 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-adt

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

We can use Base::contains.


---
Full diff: https://github.com/llvm/llvm-project/pull/157325.diff


1 Files Affected:

- (modified) llvm/include/llvm/ADT/StringSet.h (+1-1) 


``````````diff
diff --git a/llvm/include/llvm/ADT/StringSet.h b/llvm/include/llvm/ADT/StringSet.h
index 13d2c406c4ff2..b4853423a1ef3 100644
--- a/llvm/include/llvm/ADT/StringSet.h
+++ b/llvm/include/llvm/ADT/StringSet.h
@@ -57,7 +57,7 @@ class StringSet : public StringMap<std::nullopt_t, AllocatorTy> {
   }
 
   /// Check if the set contains the given \c key.
-  bool contains(StringRef key) const { return Base::FindKey(key) != -1; }
+  bool contains(StringRef key) const { return Base::contains(key); }
 };
 
 } // end namespace llvm

``````````

</details>


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


More information about the llvm-commits mailing list