@@ -39,8 +39,7 @@ namespace llvm {
3939// /
4040// / The key and value types are derived from the Set and Vector types
4141// / respectively. This allows the vector-type operations and set-type operations
42- // / to have different types. In particular, this is useful when storing pointers
43- // / as "Foo *" values but looking them up as "const Foo *" keys.
42+ // / to have different types.
4443// /
4544// / No constraint is placed on the key and value types, although it is assumed
4645// / that value_type can be converted into key_type for insertion. Users must be
@@ -60,6 +59,9 @@ class SetVector {
6059 // excessively long linear scans from occuring.
6160 static_assert (N <= 32 , " Small size should be less than or equal to 32!" );
6261
62+ using const_arg_type =
63+ typename const_pointer_or_const_ref<typename Set::key_type>::type;
64+
6365public:
6466 using value_type = typename Vector::value_type;
6567 using key_type = typename Set::key_type;
@@ -247,17 +249,17 @@ class SetVector {
247249 }
248250
249251 // / Check if the SetVector contains the given key.
250- [[nodiscard]] bool contains (const key_type & key) const {
252+ [[nodiscard]] bool contains (const_arg_type key) const {
251253 if constexpr (canBeSmall ())
252254 if (isSmall ())
253255 return is_contained (vector_, key);
254256
255- return set_. find (key) != set_. end ( );
257+ return is_contained ( set_, key );
256258 }
257259
258260 // / Count the number of elements of a given key in the SetVector.
259261 // / \returns 0 if the element is not in the SetVector, 1 if it is.
260- [[nodiscard]] size_type count (const key_type & key) const {
262+ [[nodiscard]] size_type count (const_arg_type key) const {
261263 return contains (key) ? 1 : 0 ;
262264 }
263265
0 commit comments