From 9dc19c45a763fe7c8affce45258ab131d3e99712 Mon Sep 17 00:00:00 2001 From: Alex Ainscow Date: Thu, 27 Mar 2025 11:44:29 +0000 Subject: [PATCH] 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 --- src/common/bitset_set.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/bitset_set.h b/src/common/bitset_set.h index 12c98de99a4cb..d6d0214495983 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)); } -- 2.39.5