using BoxedNode alias instead of Rc<Node>
This commit is contained in:
		
							parent
							
								
									6762812ec5
								
							
						
					
					
						commit
						e1f59b1b46
					
				| 
						 | 
					@ -25,7 +25,7 @@ pub struct BTreeLeafNode {
 | 
				
			||||||
#[derive(Debug, Clone)]
 | 
					#[derive(Debug, Clone)]
 | 
				
			||||||
pub enum NodePtr {
 | 
					pub enum NodePtr {
 | 
				
			||||||
    Unvisited(KeyPtr),
 | 
					    Unvisited(KeyPtr),
 | 
				
			||||||
    Visited { key: KeyPtr, node: Rc<Node> }, // TODO: this doesnt need to be an Rc, can just be a NonNull with manual memory management
 | 
					    Visited { key: KeyPtr, node: BoxedNode }, // TODO: this doesnt need to be an Rc, can just be a NonNull with manual memory management
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl NodePtr {
 | 
					impl NodePtr {
 | 
				
			||||||
| 
						 | 
					@ -36,7 +36,7 @@ impl NodePtr {
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn node(&self) -> Option<&Rc<Node>> {
 | 
					    pub fn node(&self) -> Option<&BoxedNode> {
 | 
				
			||||||
        match self {
 | 
					        match self {
 | 
				
			||||||
            NodePtr::Unvisited(_) => None,
 | 
					            NodePtr::Unvisited(_) => None,
 | 
				
			||||||
            NodePtr::Visited { node, .. } => Some(&node),
 | 
					            NodePtr::Visited { node, .. } => Some(&node),
 | 
				
			||||||
| 
						 | 
					@ -62,7 +62,7 @@ impl BTreeInternalNode {
 | 
				
			||||||
        &self,
 | 
					        &self,
 | 
				
			||||||
        idx: usize,
 | 
					        idx: usize,
 | 
				
			||||||
        volume: &super::volume::Volume<R>,
 | 
					        volume: &super::volume::Volume<R>,
 | 
				
			||||||
    ) -> Result<Rc<Node>> {
 | 
					    ) -> Result<BoxedNode> {
 | 
				
			||||||
        match self.children.get(idx) {
 | 
					        match self.children.get(idx) {
 | 
				
			||||||
            Some(child) => self.visit_child_inner(child, volume),
 | 
					            Some(child) => self.visit_child_inner(child, volume),
 | 
				
			||||||
            None => Err(Error::OutOfBounds {
 | 
					            None => Err(Error::OutOfBounds {
 | 
				
			||||||
| 
						 | 
					@ -76,7 +76,7 @@ impl BTreeInternalNode {
 | 
				
			||||||
        &self,
 | 
					        &self,
 | 
				
			||||||
        child: &Cell<NodePtr>,
 | 
					        child: &Cell<NodePtr>,
 | 
				
			||||||
        volume: &super::volume::Volume<R>,
 | 
					        volume: &super::volume::Volume<R>,
 | 
				
			||||||
    ) -> Result<Rc<Node>> {
 | 
					    ) -> Result<BoxedNode> {
 | 
				
			||||||
        match unsafe { &*child.as_ptr() } {
 | 
					        match unsafe { &*child.as_ptr() } {
 | 
				
			||||||
            NodePtr::Unvisited(keyptr) => {
 | 
					            NodePtr::Unvisited(keyptr) => {
 | 
				
			||||||
                let node = volume
 | 
					                let node = volume
 | 
				
			||||||
| 
						 | 
					@ -105,7 +105,7 @@ impl BTreeInternalNode {
 | 
				
			||||||
    pub fn visit_children<'a, 'b, R: super::Read>(
 | 
					    pub fn visit_children<'a, 'b, R: super::Read>(
 | 
				
			||||||
        &'a self,
 | 
					        &'a self,
 | 
				
			||||||
        volume: &'b super::volume::Volume<R>,
 | 
					        volume: &'b super::volume::Volume<R>,
 | 
				
			||||||
    ) -> impl Iterator<Item = (usize, Result<Rc<Node>>)> + 'a
 | 
					    ) -> impl Iterator<Item = (usize, Result<BoxedNode>)> + 'a
 | 
				
			||||||
    where
 | 
					    where
 | 
				
			||||||
        'b: 'a,
 | 
					        'b: 'a,
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					@ -680,7 +680,7 @@ where
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pub fn new(volume: Rc<Volume<R>>, start: Rc<Node>, end: Rc<Node>) -> Self {
 | 
					    pub fn new(volume: Rc<Volume<R>>, start: BoxedNode, end: BoxedNode) -> Self {
 | 
				
			||||||
        Self::from_handles(volume, NodeHandle::start(start), NodeHandle::end(end))
 | 
					        Self::from_handles(volume, NodeHandle::start(start), NodeHandle::end(end))
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue