Skip to content

Commit 10f7844

Browse files
[ADT] Implement DenseSetImpl::contains in terms of DenseMap::contains (NFC)
DenseSetImpl::contains can directly use DenseMap::contains. While I am at it, this patch moves count() immediately after contains() and annotates both functions with [[nodiscard].
1 parent 523c006 commit 10f7844

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

llvm/include/llvm/ADT/DenseSet.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ class DenseSetImpl {
9797

9898
void clear() { TheMap.clear(); }
9999

100-
/// Return 1 if the specified key is in the set, 0 otherwise.
101-
size_type count(const_arg_type_t<ValueT> V) const { return TheMap.count(V); }
102-
103100
bool erase(const ValueT &V) { return TheMap.erase(V); }
104101

105102
void swap(DenseSetImpl &RHS) { TheMap.swap(RHS.TheMap); }
@@ -169,8 +166,13 @@ class DenseSetImpl {
169166
}
170167

171168
/// Check if the set contains the given element.
172-
bool contains(const_arg_type_t<ValueT> V) const {
173-
return TheMap.find(V) != TheMap.end();
169+
[[nodiscard]] bool contains(const_arg_type_t<ValueT> V) const {
170+
return TheMap.contains(V);
171+
}
172+
173+
/// Return 1 if the specified key is in the set, 0 otherwise.
174+
[[nodiscard]] size_type count(const_arg_type_t<ValueT> V) const {
175+
return TheMap.count(V);
174176
}
175177

176178
/// Alternative version of find() which allows a different, and possibly less

0 commit comments

Comments
 (0)