fix: remove needless check

This commit is contained in:
Zixuan Chen 2022-12-12 16:18:55 +08:00
parent dc4229d609
commit 90fe4cc69e
2 changed files with 6 additions and 1 deletions

View file

@ -477,6 +477,7 @@ impl<'bump, T: Rle, A: RleTreeTrait<T>> LeafNode<'bump, T, A> {
ans
}
// TODO: refactor
pub(crate) fn apply_updates<F>(
&mut self,
mut updates: Vec<(usize, SmallVec<[T; 4]>)>,
@ -506,6 +507,7 @@ impl<'bump, T: Rle, A: RleTreeTrait<T>> LeafNode<'bump, T, A> {
}
}
// TODO: try merging here?
Ok(A::update_cache_leaf(self))
} else {
let mut new_children: SmallVec<[_; 64]> = SmallVec::new();

View file

@ -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<usize> {
debug_assert!(num >= min);
if num <= max {
return vec![num];
}
let n = num / min;
let mut arr = vec![min; n];
num -= n * min;