Skip to content

Commit

Permalink
Rollup merge of #48402 - eddyb:y-u-no-inline, r=nikomatsakis
Browse files Browse the repository at this point in the history
rustc_data_structures: add missing #[inline].

r? @nikomatsakis
  • Loading branch information
Manishearth committed Feb 24, 2018
2 parents fc7caed + 713b05f commit 6ec5dc3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/librustc_data_structures/bitslice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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={}",
Expand All @@ -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={}",
Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_data_structures/indexed_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
}

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 6ec5dc3

Please sign in to comment.