about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
diff options
context:
space:
mode:
authorAleksey Kladov <aleksey.kladov@gmail.com>2020-09-03 23:26:59 +0200
committerAleksey Kladov <aleksey.kladov@gmail.com>2020-09-03 23:28:22 +0200
commit09d3db2e590030de8ae7d00589f8a174e5f51f03 (patch)
treecc54fc9fa0bf826c873c3fb060069fd45cfeb58e /compiler/rustc_ast/src
parent850c3219fb8659608eb62cd43eaee29e9e354379 (diff)
downloadrust-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.rs4
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)
     }
 }