Skip to content

Commit

Permalink
chore: remove num_children calculation from twig
Browse files Browse the repository at this point in the history
  • Loading branch information
arriqaaq committed Oct 14, 2024
1 parent 6affdca commit f860bc3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/art.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<P: KeyTrait, V: Clone> Node<P, V> {
NodeType::Node16(n) => n.num_children(),
NodeType::Node48(n) => n.num_children(),
NodeType::Node256(n) => n.num_children(),
NodeType::Twig(n) => n.num_children(),
NodeType::Twig(_) => 0,
}
}

Expand Down
11 changes: 3 additions & 8 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,7 @@ impl<K: KeyTrait, V: Clone> TwigNode<K, V> {
}
}

#[inline(always)]
pub fn num_children(&self) -> usize {
self.values.len()
}

pub fn version(&self) -> u64 {
pub(crate) fn version(&self) -> u64 {
self.values
.iter()
.map(|value| value.version)
Expand Down Expand Up @@ -284,12 +279,12 @@ impl<P: KeyTrait, N: Version, const WIDTH: usize> FlatNode<P, N, WIDTH> {
new_node
}

pub fn get_value_if_single_child(&self) -> (&P, Option<Arc<N>>) {
pub(crate) fn get_value_if_single_child(&self) -> (&P, Option<Arc<N>>) {
assert_eq!(self.num_children, 1);
(&self.prefix, self.children[0].clone())
}

pub fn grow(&self) -> Node48<P, N> {
pub(crate) fn grow(&self) -> Node48<P, N> {
let mut n48 = Node48::new(self.prefix.clone());
for i in 0..self.num_children as usize {
if let Some(child) = self.children[i].as_ref() {
Expand Down

0 comments on commit f860bc3

Please sign in to comment.