use remove_range_closed for clarity (#3088)

This commit is contained in:
Antioch Peverell 2019-10-07 21:01:44 +01:00 committed by GitHub
parent 94b351beac
commit 39016faf52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,10 +115,8 @@ impl LeafSet {
// First remove pos from leaf_set that were
// added after the point we are rewinding to.
let marker_from = cutoff_pos;
let marker_to = self.bitmap.maximum() as u64;
let rewind_add_pos: Bitmap = ((marker_from + 1)..=marker_to).map(|x| x as u32).collect();
bitmap.andnot_inplace(&rewind_add_pos);
let to_remove = ((cutoff_pos + 1) as u32)..bitmap.maximum();
bitmap.remove_range_closed(to_remove);
// Then add back output pos to the leaf_set
// that were removed.
@ -136,10 +134,8 @@ impl LeafSet {
pub fn rewind(&mut self, cutoff_pos: u64, rewind_rm_pos: &Bitmap) {
// First remove pos from leaf_set that were
// added after the point we are rewinding to.
let marker_from = cutoff_pos;
let marker_to = self.bitmap.maximum() as u64;
let rewind_add_pos: Bitmap = ((marker_from + 1)..=marker_to).map(|x| x as u32).collect();
self.bitmap.andnot_inplace(&rewind_add_pos);
let to_remove = ((cutoff_pos + 1) as u32)..self.bitmap.maximum();
self.bitmap.remove_range_closed(to_remove);
// Then add back output pos to the leaf_set
// that were removed.