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 f46d021 commit a5ffcf6
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
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 a5ffcf6

Please sign in to comment.