Inline NodeIndex methods.

Because they are small and hot.
This commit is contained in:
Nicholas Nethercote 2018-05-30 16:58:48 +10:00
parent f46d0213e4
commit a5ffcf6dd8

View File

@ -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
}