Simplify bits_for_tags
impl
This commit is contained in:
parent
7cfecf26f7
commit
ad8c7b6705
1 changed files with 3 additions and 13 deletions
|
@ -155,7 +155,9 @@ pub const fn bits_for_tags(mut tags: &[usize]) -> u32 {
|
|||
while let &[tag, ref rest @ ..] = tags {
|
||||
tags = rest;
|
||||
|
||||
let b = bits_for_tag(tag);
|
||||
// bits required to represent `tag`,
|
||||
// position of the most significant 1
|
||||
let b = usize::BITS - tag.leading_zeros();
|
||||
if b > bits {
|
||||
bits = b;
|
||||
}
|
||||
|
@ -164,18 +166,6 @@ pub const fn bits_for_tags(mut tags: &[usize]) -> u32 {
|
|||
bits
|
||||
}
|
||||
|
||||
/// Returns `(size_of::<usize>() * 8) - tag.leading_zeros()`
|
||||
const fn bits_for_tag(mut tag: usize) -> u32 {
|
||||
let mut bits = 0;
|
||||
|
||||
while tag > 0 {
|
||||
bits += 1;
|
||||
tag >>= 1;
|
||||
}
|
||||
|
||||
bits
|
||||
}
|
||||
|
||||
unsafe impl<T: ?Sized + Aligned> Pointer for Box<T> {
|
||||
const BITS: u32 = bits_for::<Self::Target>();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue