Better use deserialize_unchecked_from to reduce the deserialization time

This commit is contained in:
Kerollmops 2023-05-30 14:49:32 +02:00
parent fdb23132d4
commit da04edff8c
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 3 additions and 3 deletions

View File

@ -49,7 +49,7 @@ impl CboRoaringBitmapCodec {
} else { } else {
// Otherwise, it means we used the classic RoaringBitmapCodec and // Otherwise, it means we used the classic RoaringBitmapCodec and
// that the header takes threshold integers. // that the header takes threshold integers.
RoaringBitmap::deserialize_from(bytes) RoaringBitmap::deserialize_unchecked_from(bytes)
} }
} }
@ -69,7 +69,7 @@ impl CboRoaringBitmapCodec {
vec.push(integer); vec.push(integer);
} }
} else { } else {
roaring |= RoaringBitmap::deserialize_from(bytes.as_ref())?; roaring |= RoaringBitmap::deserialize_unchecked_from(bytes.as_ref())?;
} }
} }

View File

@ -8,7 +8,7 @@ impl heed::BytesDecode<'_> for RoaringBitmapCodec {
type DItem = RoaringBitmap; type DItem = RoaringBitmap;
fn bytes_decode(bytes: &[u8]) -> Option<Self::DItem> { fn bytes_decode(bytes: &[u8]) -> Option<Self::DItem> {
RoaringBitmap::deserialize_from(bytes).ok() RoaringBitmap::deserialize_unchecked_from(bytes).ok()
} }
} }