(offset_buffer: &MutableBuffer)
| 47 | |
| 48 | #[inline] |
| 49 | pub(super) unsafe fn get_last_offset<T: ArrowNativeType>(offset_buffer: &MutableBuffer) -> T { |
| 50 | // JUSTIFICATION |
| 51 | // Benefit |
| 52 | // 20% performance improvement extend of variable sized arrays (see bench `mutable_array`) |
| 53 | // Soundness |
| 54 | // * offset buffer is always extended in slices of T and aligned accordingly. |
| 55 | // * Buffer[0] is initialized with one element, 0, and thus `mutable_offsets.len() - 1` is always valid. |
| 56 | let (prefix, offsets, suffix) = unsafe { offset_buffer.as_slice().align_to::<T>() }; |
| 57 | debug_assert!(prefix.is_empty() && suffix.is_empty()); |
| 58 | *unsafe { offsets.get_unchecked(offsets.len() - 1) } |
| 59 | } |
| 60 | |
| 61 | #[cfg(test)] |
| 62 | mod tests { |
no test coverage detected