Skip to content

Commit

Permalink
Inline NodeIndex methods.
Browse files Browse the repository at this point in the history
Because they are small and hot.
  • Loading branch information
nnethercote committed May 30, 2018
1 parent 07b9d17 commit b43f76e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/librustc_data_structures/obligation_forest/node_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ pub struct NodeIndex {
}

impl NodeIndex {
#[inline]
pub fn new(value: usize) -> NodeIndex {
assert!(value < (u32::MAX as usize));
NodeIndex { index: NonZeroU32::new((value as u32) + 1).unwrap() }
}

#[inline]
pub fn get(self) -> usize {
(self.index.get() - 1) as usize
}
Expand Down

0 comments on commit b43f76e

Please sign in to comment.