aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-05-23 14:05:22 +0100
committerEdwin Cheng <[email protected]>2019-05-23 14:05:22 +0100
commit63b67134fdbfedfeab655ac9ff03730575fdf475 (patch)
treea2b9b98c5efa889c4eb8458132b395ef8040b214
parent27ae626cfb073f8d43c197f0d67f066bd429b0fb (diff)
Use slice instead of Vec
-rw-r--r--crates/ra_tt/src/buffer.rs8
1 files 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 {
29 pub fn new(tokens: &[TokenTree]) -> TokenBuffer { 29 pub fn new(tokens: &[TokenTree]) -> TokenBuffer {
30 let mut buffers = vec![]; 30 let mut buffers = vec![];
31 31
32 let idx = TokenBuffer::new_inner(tokens.to_vec(), &mut buffers, None); 32 let idx = TokenBuffer::new_inner(tokens, &mut buffers, None);
33 assert_eq!(idx, 0); 33 assert_eq!(idx, 0);
34 34
35 TokenBuffer { buffers } 35 TokenBuffer { buffers }
36 } 36 }
37 37
38 fn new_inner( 38 fn new_inner(
39 tokens: Vec<TokenTree>, 39 tokens: &[TokenTree],
40 buffers: &mut Vec<Box<[Entry]>>, 40 buffers: &mut Vec<Box<[Entry]>>,
41 next: Option<EntryPtr>, 41 next: Option<EntryPtr>,
42 ) -> usize { 42 ) -> usize {
43 let mut entries = vec![]; 43 let mut entries = vec![];
44 let mut children = vec![]; 44 let mut children = vec![];
45 45
46 for (idx, tt) in tokens.into_iter().enumerate() { 46 for (idx, tt) in tokens.iter().cloned().enumerate() {
47 match tt { 47 match tt {
48 TokenTree::Leaf(leaf) => { 48 TokenTree::Leaf(leaf) => {
49 entries.push(Entry::Leaf(leaf)); 49 entries.push(Entry::Leaf(leaf));
@@ -61,7 +61,7 @@ impl TokenBuffer {
61 61
62 for (child_idx, subtree) in children { 62 for (child_idx, subtree) in children {
63 let idx = TokenBuffer::new_inner( 63 let idx = TokenBuffer::new_inner(
64 subtree.token_trees.clone(), 64 &subtree.token_trees,
65 buffers, 65 buffers,
66 Some(EntryPtr(EntryId(res), child_idx + 1)), 66 Some(EntryPtr(EntryId(res), child_idx + 1)),
67 ); 67 );