From 4696b8199f6206ff2c496e63049458af4fc40e02 Mon Sep 17 00:00:00 2001 From: Tamo Date: Tue, 24 Oct 2023 16:03:10 +0200 Subject: [PATCH] 2 additional precent won by reserving the memory before pushing in the vec --- milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs b/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs index 4c40ac7b1..ef37ddc8b 100644 --- a/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs +++ b/milli/src/heed_codec/roaring_bitmap/cbo_roaring_bitmap_codec.rs @@ -71,6 +71,7 @@ impl CboRoaringBitmapCodec { for bytes in slices { if bytes.len() <= THRESHOLD * size_of::() { debug_assert!(bytes.len() % size_of::() == 0); + vec.reserve(bytes.len() / size_of::()); for bytes in bytes.chunks_exact(size_of::()) { // unwrap can't happens since we ensured that everything