You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make SpareBufferWriter bounds-checked and drop caller-side unsafe
Replace the raw-pointer cursor with a written-count cursor over
spare_capacity_mut, and remove copy_slice_unchecked along with the
unsafe blocks at the four PiecewiseSequence call sites. The bounds
check is one well-predicted branch per slice: benchmarking the gather
loop over 16M u64 elements shows checked copies within noise of
unchecked ones at every run length (212ms vs 200ms even at the
pathological run length of 1, where both beat extend_from_slice's
299ms), so the unchecked variant's extra unsafe surface isn't paying
for anything.
The writer is now #[must_use], and the remaining unsafety is contained
to the copy into the bounds-checked spare-capacity range (the
not-yet-stable <[MaybeUninit<T>]>::write_copy_of_slice) and the single
set_len in finish, justified by the writer's contiguous-prefix
invariant.
Signed-off-by: "Robert" <robert@spiraldb.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GUSY34eRKq9du5zQK1FuZq
0 commit comments