Skip to content

Commit

Permalink
Shrink main hashmap after blocks are no longer being added
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev authored and goffrie committed Sep 13, 2021
1 parent c011a8d commit 66baacc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ impl<'a> Signature<'a> {
.or_default()
.insert(block.crypto_hash, idx as u32);
}

// Multiple blocks having the same `Crc` value means that the hashmap will reserve more
// capacity than needed. This is particularly noticable when `self.blocks` contains a very
// large number of values
blocks.shrink_to_fit();

IndexedSignature {
signature_type: self.signature_type,
block_size: self.block_size,
Expand Down

0 comments on commit 66baacc

Please sign in to comment.