diff --git a/crates/rle/src/rle_tree/node/leaf_impl.rs b/crates/rle/src/rle_tree/node/leaf_impl.rs index 941c13b5..b1e5a4c4 100644 --- a/crates/rle/src/rle_tree/node/leaf_impl.rs +++ b/crates/rle/src/rle_tree/node/leaf_impl.rs @@ -477,6 +477,7 @@ impl<'bump, T: Rle, A: RleTreeTrait> LeafNode<'bump, T, A> { ans } + // TODO: refactor pub(crate) fn apply_updates( &mut self, mut updates: Vec<(usize, SmallVec<[T; 4]>)>, @@ -506,6 +507,7 @@ impl<'bump, T: Rle, A: RleTreeTrait> LeafNode<'bump, T, A> { } } + // TODO: try merging here? Ok(A::update_cache_leaf(self)) } else { let mut new_children: SmallVec<[_; 64]> = SmallVec::new(); diff --git a/crates/rle/src/rle_tree/node/utils.rs b/crates/rle/src/rle_tree/node/utils.rs index be07aab6..1f5d6573 100644 --- a/crates/rle/src/rle_tree/node/utils.rs +++ b/crates/rle/src/rle_tree/node/utils.rs @@ -1,7 +1,10 @@ /// distribute the num to a array, where the sum of the array is num /// and each element is in the range [min, max] pub(super) fn distribute(mut num: usize, min: usize, max: usize) -> Vec { - debug_assert!(num >= min); + if num <= max { + return vec![num]; + } + let n = num / min; let mut arr = vec![min; n]; num -= n * min;