mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-16 21:15:18 +03:00
Inline NodeIndex methods.
Because they are small and hot.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user