From 5e1dc927c3431a1d7cd271bc2f18071c8fe0817a Mon Sep 17 00:00:00 2001 From: Jiseok CHOI Date: Fri, 14 Feb 2025 17:43:35 +0900 Subject: [PATCH] perf(node): replace `std::array::from_fn` with const block initializer (#87) --- src/node.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node.rs b/src/node.rs index 5b5e41c..1a30684 100644 --- a/src/node.rs +++ b/src/node.rs @@ -245,7 +245,7 @@ pub(crate) struct FlatNode { impl FlatNode { pub(crate) fn new(prefix: P) -> Self { - let children: [Option>; WIDTH] = std::array::from_fn(|_| None); + let children: [Option>; WIDTH] = [const { None }; WIDTH]; Self { prefix, @@ -410,7 +410,7 @@ impl Node48 { 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, } @@ -554,7 +554,7 @@ impl Node256 { 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, }