This bitset_set change relaxes policing of bitset_set, so that
out-of-range can be queried in the contains interface. This means
that callers cam simplifiy calls. For example:
if (key == invalid) || !set.contains(key)) {
do_stuff
}
becomes
if (!set.contains(key)) {
do_stuff
}
Signed-off-by: Alex Ainscow <aainscow@uk.ibm.com>
/** @return true if the container contains Key k. */
bool contains(KeyT k) const {
- ceph_assert(unsigned_cast(k) < max_bits);
- ceph_assert(int(k) >= 0);
+ if (unsigned_cast(k) >= max_bits) {
+ return false;
+ }
return (words[int(k) / bits_per_uint64_t]
& 1ULL << (int(k) % bits_per_uint64_t));
}