Use boxed sliced for red nodes

This commit is contained in:
Aleksey Kladov 2018-07-30 18:14:14 +03:00
parent beaddb4780
commit 6fc66c4ee6
2 changed files with 4 additions and 3 deletions

View file

@ -150,6 +150,5 @@ Grammar(
"LIFETIME_PARAM", "LIFETIME_PARAM",
"TYPE_PARAM_LIST", "TYPE_PARAM_LIST",
"TYPE_ARG_LIST", "TYPE_ARG_LIST",
] ]
) )

View file

@ -5,7 +5,7 @@ use {yellow::GreenNode, TextUnit};
pub(crate) struct RedNode { pub(crate) struct RedNode {
green: GreenNode, green: GreenNode,
parent: Option<ParentData>, parent: Option<ParentData>,
children: RwLock<Vec<Option<RedNode>>>, children: RwLock<Box<[Option<RedNode>]>>,
} }
#[derive(Debug)] #[derive(Debug)]
@ -36,7 +36,9 @@ impl RedNode {
fn new(green: GreenNode, parent: Option<ParentData>) -> RedNode { fn new(green: GreenNode, parent: Option<ParentData>) -> RedNode {
let n_children = green.children().len(); let n_children = green.children().len();
let children = (0..n_children).map(|_| None).collect(); let children = (0..n_children).map(|_| None)
.collect::<Vec<_>>()
.into_boxed_slice();
RedNode { RedNode {
green, green,
parent, parent,