diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2018-02-24 08:55:53 -0800 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2018-02-24 12:48:02 -0800 |
| commit | 6ec5dc399c84837e2b81c9df8407b2b83c9fb437 (patch) | |
| tree | 8ae1f1becf035a8a8e4f109fc8c3cc93c8867fe1 /src/librustc_data_structures | |
| parent | fc7caed04ed500ee1f4f3c1422b2752b7beafa62 (diff) | |
| parent | 713b05f0726b7ee4c45728c01ddb0c40d8ccf0f3 (diff) | |
| download | rust-6ec5dc399c84837e2b81c9df8407b2b83c9fb437.tar.gz rust-6ec5dc399c84837e2b81c9df8407b2b83c9fb437.zip | |
Rollup merge of #48402 - eddyb:y-u-no-inline, r=nikomatsakis
rustc_data_structures: add missing #[inline]. r? @nikomatsakis
Diffstat (limited to 'src/librustc_data_structures')
| -rw-r--r-- | src/librustc_data_structures/bitslice.rs | 3 | ||||
| -rw-r--r-- | src/librustc_data_structures/indexed_vec.rs | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/src/librustc_data_structures/bitslice.rs b/src/librustc_data_structures/bitslice.rs index 7665bfd5b11..2678861be06 100644 --- a/src/librustc_data_structures/bitslice.rs +++ b/src/librustc_data_structures/bitslice.rs @@ -24,6 +24,7 @@ pub trait BitSlice { impl BitSlice for [Word] { /// Clears bit at `idx` to 0; returns true iff this changed `self.` + #[inline] fn clear_bit(&mut self, idx: usize) -> bool { let words = self; debug!("clear_bit: words={} idx={}", @@ -37,6 +38,7 @@ impl BitSlice for [Word] { } /// Sets bit at `idx` to 1; returns true iff this changed `self.` + #[inline] fn set_bit(&mut self, idx: usize) -> bool { let words = self; debug!("set_bit: words={} idx={}", @@ -50,6 +52,7 @@ impl BitSlice for [Word] { } /// Extracts value of bit at `idx` in `self`. + #[inline] fn get_bit(&self, idx: usize) -> bool { let words = self; let BitLookup { word, bit_mask, .. } = bit_lookup(idx); diff --git a/src/librustc_data_structures/indexed_vec.rs b/src/librustc_data_structures/indexed_vec.rs index 3e94b3f4d30..11c2bd73687 100644 --- a/src/librustc_data_structures/indexed_vec.rs +++ b/src/librustc_data_structures/indexed_vec.rs @@ -29,12 +29,16 @@ pub trait Idx: Copy + 'static + Eq + Debug { } impl Idx for usize { + #[inline] fn new(idx: usize) -> Self { idx } + #[inline] fn index(self) -> usize { self } } impl Idx for u32 { + #[inline] fn new(idx: usize) -> Self { assert!(idx <= u32::MAX as usize); idx as u32 } + #[inline] fn index(self) -> usize { self as usize } } @@ -73,11 +77,13 @@ macro_rules! newtype_index { pub struct $type($($pub)* u32); impl Idx for $type { + #[inline] fn new(value: usize) -> Self { assert!(value < ($max) as usize); $type(value as u32) } + #[inline] fn index(self) -> usize { self.0 as usize } |
