Skip to content

Commit

Permalink
perf(node): replace std::array::from_fn with const block initializer (
Browse files Browse the repository at this point in the history
  • Loading branch information
ever0de authored Feb 14, 2025
1 parent 9dac04b commit 5e1dc92
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub(crate) struct FlatNode<P: KeyTrait, N, const WIDTH: usize> {

impl<P: KeyTrait, N, const WIDTH: usize> FlatNode<P, N, WIDTH> {
pub(crate) fn new(prefix: P) -> Self {
let children: [Option<Arc<N>>; WIDTH] = std::array::from_fn(|_| None);
let children: [Option<Arc<N>>; WIDTH] = [const { None }; WIDTH];

Self {
prefix,
Expand Down Expand Up @@ -410,7 +410,7 @@ impl<P: KeyTrait, N> Node48<P, N> {
Self {
prefix,
keys: Box::new([u8::MAX; 256]),
children: Box::new(std::array::from_fn(|_| None)),
children: Box::new([const { None }; 48]),
inner_twig: None,
child_bitmap: 0,
}
Expand Down Expand Up @@ -554,7 +554,7 @@ impl<P: KeyTrait, N> Node256<P, N> {
pub(crate) fn new(prefix: P) -> Self {
Self {
prefix,
children: Box::new(std::array::from_fn(|_| None)),
children: Box::new([const { None }; 256]),
inner_twig: None,
num_children: 0,
}
Expand Down

0 comments on commit 5e1dc92

Please sign in to comment.