Skip to content

Commit a835e8b

Browse files
authored
Add inline attributes to BitMap trait methods implementations
1 parent 03359e8 commit a835e8b

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/traits.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ pub trait BitMap<T> {
1212
macro_rules! impl_bitmap {
1313
($ty:ident) => {
1414
impl BitMap<$ty> for $ty {
15+
#[inline]
1516
fn get_bit(&self, index: u8) -> $ty {
1617
*self >> index & 0b1
1718
}
1819

20+
#[inline]
1921
fn set_bit(&mut self, index: u8, value: $ty) {
2022
*self = (*self & !(1 << index)) | ((value & 1) << index);
2123
}
2224

25+
#[inline]
2326
fn set_bits(&mut self, indices: ::core::ops::Range<u8>, value: $ty) {
2427
let width = indices.end - indices.start;
2528
let bit_count = ::core::mem::size_of::<$ty>() * 8;
@@ -29,6 +32,7 @@ macro_rules! impl_bitmap {
2932
*self = (*self & !(mask << indices.start)) | ((value & mask) << indices.start);
3033
}
3134

35+
#[inline]
3236
fn get_bits(&self, indices: ::core::ops::Range<u8>) -> $ty {
3337
let width = indices.end - indices.start;
3438
let bit_count = ::core::mem::size_of::<$ty>() * 8;

0 commit comments

Comments
 (0)