aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_mbe/src/subtree_parser.rs
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-06-02 18:09:49 +0100
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-06-02 18:09:49 +0100
commitae8fd982c05c4d825952c78d1b1d8a5cfba94e66 (patch)
treec9cdc209f904cade7bc2deac2489239da34f7126 /crates/ra_mbe/src/subtree_parser.rs
parentb40c6de8a6887e6c184fca5c9188d26ee402df23 (diff)
parent824f413d75b68e950726dc17c4e7cc3d3f241eda (diff)
Merge #1368
1368: Store referece instead of full token tree in tokenbuffer r=matklad a=edwin0cheng This PR try to minimize the memory allocation in converting `SyntaxNode` to `TokenTree` by using reference isnteead of full token tree in `TokenBuffer`. Note that the final goal is replace `TokenTree` with TokenBuffer such that there is no conversion between them. Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_mbe/src/subtree_parser.rs')
-rw-r--r--crates/ra_mbe/src/subtree_parser.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/crates/ra_mbe/src/subtree_parser.rs b/crates/ra_mbe/src/subtree_parser.rs
index 1f12e42ef..4a6f6aa45 100644
--- a/crates/ra_mbe/src/subtree_parser.rs
+++ b/crates/ra_mbe/src/subtree_parser.rs
@@ -10,7 +10,7 @@ struct OffsetTokenSink<'a> {
10} 10}
11 11
12impl<'a> OffsetTokenSink<'a> { 12impl<'a> OffsetTokenSink<'a> {
13 pub fn collect(&self, begin: Cursor<'a>) -> Vec<tt::TokenTree> { 13 pub fn collect(&self, begin: Cursor<'a>) -> Vec<&'a tt::TokenTree> {
14 if !self.cursor.is_root() { 14 if !self.cursor.is_root() {
15 return vec![]; 15 return vec![];
16 } 16 }
@@ -114,7 +114,7 @@ impl<'a> Parser<'a> {
114 1 => Some(res[0].clone()), 114 1 => Some(res[0].clone()),
115 _ => Some(tt::TokenTree::Subtree(tt::Subtree { 115 _ => Some(tt::TokenTree::Subtree(tt::Subtree {
116 delimiter: tt::Delimiter::None, 116 delimiter: tt::Delimiter::None,
117 token_trees: res, 117 token_trees: res.into_iter().cloned().collect(),
118 })), 118 })),
119 } 119 }
120 } 120 }