Reduce memory allocations in PMMR (#3328)

We have a pattern in the code - return Vec, turn it into an iterator, filter and collect to another Vec. The idea was to return iterator where possible to avoid allocating intermediate vecs.
This commit is contained in:
hashmap
2020-05-24 17:50:27 +02:00
committed by GitHub
parent 6faa0e8d75
commit 26b411e79e
4 changed files with 63 additions and 40 deletions
+1 -2
View File
@@ -279,8 +279,7 @@ impl PruneList {
let maximum = self.bitmap.maximum().unwrap_or(0);
self.pruned_cache = Bitmap::create_with_capacity(maximum);
for pos in 1..(maximum + 1) {
let path = path(pos as u64, maximum as u64);
let pruned = path.into_iter().any(|x| self.bitmap.contains(x as u32));
let pruned = path(pos as u64, maximum as u64).any(|x| self.bitmap.contains(x as u32));
if pruned {
self.pruned_cache.add(pos as u32)
}