diff options
author | Aleksey Kladov <[email protected]> | 2018-08-08 23:59:36 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-08-08 23:59:36 +0100 |
commit | 7974c6b1a0b2d07c5a337c89a70a51e01f629778 (patch) | |
tree | 7bae3e37fd6be0171789bba5f3965056649f79c5 /src/yellow | |
parent | f4d294f32c570a8b5494e288eae8652bc2372bb9 (diff) |
Mincrooptimization
Diffstat (limited to 'src/yellow')
-rw-r--r-- | src/yellow/builder.rs | 4 | ||||
-rw-r--r-- | src/yellow/green.rs | 8 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/yellow/builder.rs b/src/yellow/builder.rs index 70869952c..878f3ba39 100644 --- a/src/yellow/builder.rs +++ b/src/yellow/builder.rs | |||
@@ -41,11 +41,11 @@ impl<'a> Sink<'a> for GreenBuilder<'a> { | |||
41 | 41 | ||
42 | fn finish_internal(&mut self) { | 42 | fn finish_internal(&mut self) { |
43 | let (kind, first_child) = self.parents.pop().unwrap(); | 43 | let (kind, first_child) = self.parents.pop().unwrap(); |
44 | let children = self.children | 44 | let children: Vec<_> = self.children |
45 | .drain(first_child..) | 45 | .drain(first_child..) |
46 | .collect(); | 46 | .collect(); |
47 | self.children.push( | 47 | self.children.push( |
48 | GreenNode::new_branch(kind, children) | 48 | GreenNode::new_branch(kind, children.into_boxed_slice()) |
49 | ); | 49 | ); |
50 | } | 50 | } |
51 | 51 | ||
diff --git a/src/yellow/green.rs b/src/yellow/green.rs index 5b4ce313a..57579a8f2 100644 --- a/src/yellow/green.rs +++ b/src/yellow/green.rs | |||
@@ -16,7 +16,7 @@ impl GreenNode { | |||
16 | GreenNode::Leaf(GreenLeaf::new(kind, text)) | 16 | GreenNode::Leaf(GreenLeaf::new(kind, text)) |
17 | } | 17 | } |
18 | 18 | ||
19 | pub(crate) fn new_branch(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenNode { | 19 | pub(crate) fn new_branch(kind: SyntaxKind, children: Box<[GreenNode]>) -> GreenNode { |
20 | GreenNode::Branch(Arc::new(GreenBranch::new(kind, children))) | 20 | GreenNode::Branch(Arc::new(GreenBranch::new(kind, children))) |
21 | } | 21 | } |
22 | 22 | ||
@@ -64,11 +64,11 @@ fn assert_send_sync() { | |||
64 | pub(crate) struct GreenBranch { | 64 | pub(crate) struct GreenBranch { |
65 | text_len: TextUnit, | 65 | text_len: TextUnit, |
66 | kind: SyntaxKind, | 66 | kind: SyntaxKind, |
67 | children: Vec<GreenNode>, | 67 | children: Box<[GreenNode]>, |
68 | } | 68 | } |
69 | 69 | ||
70 | impl GreenBranch { | 70 | impl GreenBranch { |
71 | fn new(kind: SyntaxKind, children: Vec<GreenNode>) -> GreenBranch { | 71 | fn new(kind: SyntaxKind, children: Box<[GreenNode]>) -> GreenBranch { |
72 | let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>(); | 72 | let text_len = children.iter().map(|x| x.text_len()).sum::<TextUnit>(); |
73 | GreenBranch { | 73 | GreenBranch { |
74 | text_len, | 74 | text_len, |
@@ -86,7 +86,7 @@ impl GreenBranch { | |||
86 | } | 86 | } |
87 | 87 | ||
88 | pub fn children(&self) -> &[GreenNode] { | 88 | pub fn children(&self) -> &[GreenNode] { |
89 | self.children.as_slice() | 89 | &*self.children |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||