1
Fork 0

Optimize Cursor::look_ahead

Cloning a tt is cheap, but not free (there's Arc inside).
This commit is contained in:
Aleksey Kladov 2020-09-03 23:26:59 +02:00
parent 850c3219fb
commit 09d3db2e59
3 changed files with 15 additions and 10 deletions

View file

@ -403,8 +403,8 @@ impl Cursor {
self.index = index;
}
pub fn look_ahead(&self, n: usize) -> Option<TokenTree> {
self.stream.0[self.index..].get(n).map(|(tree, _)| tree.clone())
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree> {
self.stream.0[self.index..].get(n).map(|(tree, _)| tree)
}
}