Introduced Cursor::next_with_spacing_ref
.
This lets us clone just the parts within a `TokenTree` that need cloning, rather than the entire thing. This is a surprisingly large performance win, up to 4% on `async-std-1.10.0`.
This commit is contained in:
parent
cc4e3443ec
commit
643e9f707e
2 changed files with 13 additions and 5 deletions
|
@ -583,6 +583,14 @@ impl Cursor {
|
|||
})
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn next_with_spacing_ref(&mut self) -> Option<&TreeAndSpacing> {
|
||||
self.stream.0.get(self.index).map(|tree| {
|
||||
self.index += 1;
|
||||
tree
|
||||
})
|
||||
}
|
||||
|
||||
pub fn index(&self) -> usize {
|
||||
self.index
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue