From: Alex Ainscow Date: Thu, 27 Mar 2025 11:44:29 +0000 (+0000) Subject: common: bitset_set X-Git-Tag: v20.3.0~29^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9dc19c45a763fe7c8affce45258ab131d3e99712;p=ceph.git common: bitset_set 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 --- diff --git a/src/common/bitset_set.h b/src/common/bitset_set.h index 12c98de99a4c..d6d021449598 100644 --- a/src/common/bitset_set.h +++ b/src/common/bitset_set.h @@ -260,8 +260,9 @@ class bitset_set { /** @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)); }