From 816db7a0aa6c45d6695f7c2ab9bb6bed28a2ebc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Sat, 29 Aug 2020 11:21:30 +0200 Subject: [PATCH] Improve the RoaringBitmap codec to reserve enough vector space --- src/heed_codec/roaring_bitmap_codec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/heed_codec/roaring_bitmap_codec.rs b/src/heed_codec/roaring_bitmap_codec.rs index abc89e90d..755296704 100644 --- a/src/heed_codec/roaring_bitmap_codec.rs +++ b/src/heed_codec/roaring_bitmap_codec.rs @@ -15,7 +15,7 @@ impl heed::BytesEncode<'_> for RoaringBitmapCodec { type EItem = RoaringBitmap; fn bytes_encode(item: &Self::EItem) -> Option> { - let mut bytes = Vec::new(); + let mut bytes = Vec::with_capacity(item.serialized_size()); item.serialize_into(&mut bytes).ok()?; Some(Cow::Owned(bytes)) }