Some simple Option / Result / iterator pattern simplifications (#3205)

This commit is contained in:
François Garillot
2020-01-29 09:20:57 -05:00
committed by GitHub
parent 616dad43fd
commit dcdbdd4bcc
10 changed files with 39 additions and 57 deletions
+1 -2
View File
@@ -96,8 +96,7 @@ impl LeafSet {
/// Only applicable for the output MMR.
fn unpruned_pre_cutoff(&self, cutoff_pos: u64, prune_list: &PruneList) -> Bitmap {
(1..=cutoff_pos)
.filter(|&x| pmmr::is_leaf(x))
.filter(|&x| !prune_list.is_pruned(x))
.filter(|&x| pmmr::is_leaf(x) && !prune_list.is_pruned(x))
.map(|x| x as u32)
.collect()
}
+1 -4
View File
@@ -107,10 +107,7 @@ where
/// Elements can be of variable size (handled internally in the append-only file impl).
///
pub fn read(&self, position: u64) -> Option<T> {
match self.file.read_as_elmt(position - 1) {
Ok(x) => Some(x),
Err(_) => None,
}
self.file.read_as_elmt(position - 1).ok()
}
/// Rewind the backend file to the specified position.