On Mon, Aug 17, 2026 at 9:04 AM Eliot Courtney <[email protected]> wrote:
>
> Current code in IdPool::with_capacity rounds the capacity up to
> BitmapVec::MAX_INLINE_LEN, but BitmapVec::new works fine with values
> smaller than this and still uses an inline representation. Remove this
> behaviour.
>
> Signed-off-by: Eliot Courtney <[email protected]>
> ---
>  rust/kernel/id_pool.rs | 7 +------
>  1 file changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/rust/kernel/id_pool.rs b/rust/kernel/id_pool.rs
> index 382a5645767f..3e7c3d0c9dd9 100644
> --- a/rust/kernel/id_pool.rs
> +++ b/rust/kernel/id_pool.rs
> @@ -115,14 +115,9 @@ pub fn new() -> Self {
>      }
>
>      /// Constructs a new [`IdPool`] with space for a specific number of bits.
> -    ///
> -    /// A capacity below [`MAX_INLINE_LEN`] is adjusted to 
> [`MAX_INLINE_LEN`].
> -    ///
> -    /// [`MAX_INLINE_LEN`]: BitmapVec::MAX_INLINE_LEN
>      #[inline]
>      pub fn with_capacity(num_ids: NonZero<usize>, flags: Flags) -> 
> Result<Self, AllocError> {
> -        let num_ids = usize::max(num_ids.get(), BitmapVec::MAX_INLINE_LEN);
> -        let map = BitmapVec::new(num_ids, flags)?;
> +        let map = BitmapVec::new(num_ids.get(), flags)?;
>          Ok(Self { map })
>      }

Could you modify the rustdoctest unit tests of shrink_request and
grow_request to cover a few cases where capacity is < MAX_INLINE_LEN?

- Burak

Reply via email to