diff options
| author | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-09-03 23:26:59 +0200 |
|---|---|---|
| committer | Aleksey Kladov <aleksey.kladov@gmail.com> | 2020-09-03 23:28:22 +0200 |
| commit | 09d3db2e590030de8ae7d00589f8a174e5f51f03 (patch) | |
| tree | cc54fc9fa0bf826c873c3fb060069fd45cfeb58e /compiler/rustc_ast/src | |
| parent | 850c3219fb8659608eb62cd43eaee29e9e354379 (diff) | |
| download | rust-09d3db2e590030de8ae7d00589f8a174e5f51f03.tar.gz rust-09d3db2e590030de8ae7d00589f8a174e5f51f03.zip | |
Optimize Cursor::look_ahead
Cloning a tt is cheap, but not free (there's Arc inside).
Diffstat (limited to 'compiler/rustc_ast/src')
| -rw-r--r-- | compiler/rustc_ast/src/tokenstream.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_ast/src/tokenstream.rs b/compiler/rustc_ast/src/tokenstream.rs index 151acddae84..fb98f55a215 100644 --- a/compiler/rustc_ast/src/tokenstream.rs +++ b/compiler/rustc_ast/src/tokenstream.rs @@ -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) } } |
