MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / empty_node

Method empty_node

cranelift/bforest/src/path.rs:563–589  ·  view source on GitHub ↗

The current node at `level` has become empty. Remove the node from its parent node and leave the path in a normalized state. This means that the path at this level will go through the right sibling of this node. If the current node has no right sibling, set `self.size = 0`. Returns true if the tree becomes empty.

(&mut self, level: usize, pool: &mut NodePool<F>)

Source from the content-addressed store, hash-verified

561 ///
562 /// Returns true if the tree becomes empty.
563 fn empty_node(&mut self, level: usize, pool: &mut NodePool<F>) -> bool {
564 pool.free_node(self.node[level]);
565 if level == 0 {
566 // We just deleted the root node, so the tree is now empty.
567 return true;
568 }
569
570 // Get the right sibling node before recursively removing nodes.
571 let rhs_node = self.right_sibling(level, pool).map(|(_, n)| n);
572
573 // Remove the current sub-tree from the parent node.
574 let pl = level - 1;
575 let pe = self.entry[pl].into();
576 let status = pool[self.node[pl]].inner_remove(pe);
577 self.heal_level(status, pl, pool);
578
579 // Finally update the path at this level.
580 match rhs_node {
581 // We'll leave `self.entry[level]` unchanged. It can be non-zero after moving node
582 // entries to the right sibling node.
583 Some(rhs) => self.node[level] = rhs,
584 // We have no right sibling, so we must have deleted the right-most
585 // entry. The path should be moved to the "off-the-end" position.
586 None => self.size = 0,
587 }
588 false
589 }
590
591 /// Find the level where the right sibling to the current node at `level` branches off.
592 ///

Callers 2

heal_levelMethod · 0.80
underflowed_nodeMethod · 0.80

Calls 5

free_nodeMethod · 0.80
right_siblingMethod · 0.80
inner_removeMethod · 0.80
heal_levelMethod · 0.80
mapMethod · 0.45

Tested by

no test coverage detected