From 66baaccc55ce2c8702627951408a381631bab175 Mon Sep 17 00:00:00 2001 From: Lovecraftian Horror Date: Sun, 12 Sep 2021 18:23:24 -0500 Subject: [PATCH] Shrink main hashmap after blocks are no longer being added --- src/signature.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/signature.rs b/src/signature.rs index fbc0b24..b02269c 100644 --- a/src/signature.rs +++ b/src/signature.rs @@ -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,