-
Notifications
You must be signed in to change notification settings - Fork 224
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1078 +/- ##
=======================================
Coverage 81.01% 81.01%
=======================================
Files 366 366
Lines 35056 35061 +5
=======================================
+ Hits 28399 28404 +5
Misses 6657 6657
Continue to review full report at Codecov.
|
MutableBitmap::from_vec(data.bytes.as_ref().to_vec(), data.length) | ||
if data.offset > 0 { | ||
// we have to recreate the bytes because a MutableBitmap does not have an `offset`. | ||
data.iter().collect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can improve this further by using iter_chunk
, which will iterate in chunks of u64
. We have a function somewhere to create a MutableBitmap
from chunks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, but that seems to not include the remainder
let chunks = BitChunks::<u64>::new(data.bytes.as_ref(), data.offset, data.length);
chunk_iter_to_vec(chunks)
Just to double check, before the test would panic (not trigger UB), right? |
Yes |
Thanks a lot! 🙇 |
Thelength
taken into account to compute the remainder bytes could differ from the length of the buffer (e.g. in slicing operations).This ensures we do the computations on the length of the buffer and we've added a test to ensure we don't regress.When calling
into_mut
on aBitmap
and the data has anoffset
wememcpy
the bytes into aMutableBitmap
. However this is incorrect, because aMutableBitmap
does not have an offset.This fixes that by iterating every
bit
and recreating the proper bytes for theMutableBitmap
.This is expensive, so maybe we should consider adding an
offset
onMutableBitmap
as well.