From 97bb2232797e464290d09f23fadae97db1043e34 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Jul 2018 12:46:42 +0300 Subject: Remove indirection --- src/yellow/red.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/yellow/red.rs b/src/yellow/red.rs index e0fa27e5f..3f0ddd04c 100644 --- a/src/yellow/red.rs +++ b/src/yellow/red.rs @@ -11,7 +11,7 @@ use { pub(crate) struct RedNode { green: GreenNode, parent: Option, - children: RwLock>>>, + children: RwLock>>, } #[derive(Debug)] @@ -68,7 +68,7 @@ impl RedNode { pub(crate) fn nth_child(&self, idx: usize) -> ptr::NonNull { match &self.children.read().unwrap()[idx] { - Some(child) => return ptr::NonNull::from(&**child), + Some(child) => return child.into(), None => (), } let mut children = self.children.write().unwrap(); @@ -77,10 +77,10 @@ impl RedNode { let start_offset = self.start_offset() + green_children[..idx].iter().map(|x| x.text_len()).sum::(); let child = RedNode::new_child(green_children[idx].clone(), self.into(), start_offset, idx); - children[idx] = Some(Box::new(child)) + children[idx] = Some(child) } - let child = children[idx].as_ref().unwrap(); - ptr::NonNull::from(&**child) + children[idx].as_ref().unwrap().into() + } pub(crate) fn parent(&self) -> Option> { -- cgit v1.2.3