compiler: Align::max_for_offset -> Align::max_aligned_factor
No functional changes.
This commit is contained in:
@@ -810,20 +810,19 @@ impl Align {
|
||||
self.bits().try_into().unwrap()
|
||||
}
|
||||
|
||||
/// Computes the best alignment possible for the given offset
|
||||
/// (the largest power of two that the offset is a multiple of).
|
||||
/// Obtain the greatest factor of `size` that is an alignment
|
||||
/// (the largest power of two the Size is a multiple of).
|
||||
///
|
||||
/// N.B., for an offset of `0`, this happens to return `2^64`.
|
||||
/// Note that all numbers are factors of 0
|
||||
#[inline]
|
||||
pub fn max_for_offset(offset: Size) -> Align {
|
||||
Align { pow2: offset.bytes().trailing_zeros() as u8 }
|
||||
pub fn max_aligned_factor(size: Size) -> Align {
|
||||
Align { pow2: size.bytes().trailing_zeros() as u8 }
|
||||
}
|
||||
|
||||
/// Lower the alignment, if necessary, such that the given offset
|
||||
/// is aligned to it (the offset is a multiple of the alignment).
|
||||
/// Reduces Align to an aligned factor of `size`.
|
||||
#[inline]
|
||||
pub fn restrict_for_offset(self, offset: Size) -> Align {
|
||||
self.min(Align::max_for_offset(offset))
|
||||
pub fn restrict_for_offset(self, size: Size) -> Align {
|
||||
self.min(Align::max_aligned_factor(size))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user