From 63b67134fdbfedfeab655ac9ff03730575fdf475 Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 23 May 2019 21:05:22 +0800 Subject: Use slice instead of Vec --- crates/ra_tt/src/buffer.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/ra_tt/src/buffer.rs b/crates/ra_tt/src/buffer.rs index a149205fb..56b844b8b 100644 --- a/crates/ra_tt/src/buffer.rs +++ b/crates/ra_tt/src/buffer.rs @@ -29,21 +29,21 @@ impl TokenBuffer { pub fn new(tokens: &[TokenTree]) -> TokenBuffer { let mut buffers = vec![]; - let idx = TokenBuffer::new_inner(tokens.to_vec(), &mut buffers, None); + let idx = TokenBuffer::new_inner(tokens, &mut buffers, None); assert_eq!(idx, 0); TokenBuffer { buffers } } fn new_inner( - tokens: Vec, + tokens: &[TokenTree], buffers: &mut Vec>, next: Option, ) -> usize { let mut entries = vec![]; let mut children = vec![]; - for (idx, tt) in tokens.into_iter().enumerate() { + for (idx, tt) in tokens.iter().cloned().enumerate() { match tt { TokenTree::Leaf(leaf) => { entries.push(Entry::Leaf(leaf)); @@ -61,7 +61,7 @@ impl TokenBuffer { for (child_idx, subtree) in children { let idx = TokenBuffer::new_inner( - subtree.token_trees.clone(), + &subtree.token_trees, buffers, Some(EntryPtr(EntryId(res), child_idx + 1)), ); -- cgit v1.2.3