MCPcopy Create free account
hub / github.com/apache/arrow-rs / resize

Method resize

arrow-buffer/src/buffer/mutable.rs:436–451  ·  view source on GitHub ↗
(&mut self, new_len: usize, value: u8)

Source from the content-addressed store, hash-verified

434 // exits.
435 #[inline(always)]
436 pub fn resize(&mut self, new_len: usize, value: u8) {
437 if new_len > self.len {
438 let diff = new_len - self.len;
439 self.reserve(diff);
440 // write the value
441 unsafe { self.data.as_ptr().add(self.len).write_bytes(value, diff) };
442 }
443 // this truncates the buffer when new_len < self.len
444 self.len = new_len;
445 #[cfg(feature = "pool")]
446 {
447 if let Some(reservation) = self.reservation.lock().unwrap().as_mut() {
448 reservation.resize(self.len);
449 }
450 }
451 }
452
453 /// Shrinks the capacity of the buffer as much as possible.
454 /// The new capacity will aligned to the nearest 64 bit alignment.

Callers 15

resize_reservationMethod · 0.45
reallocateMethod · 0.45
truncateMethod · 0.45
clearMethod · 0.45
extend_zerosMethod · 0.45
test_mutable_resizeFunction · 0.45
test_truncate_with_poolFunction · 0.45
test_resize_with_poolFunction · 0.45
regenMethod · 0.45
decodeMethod · 0.45

Calls 4

write_bytesMethod · 0.80
reserveMethod · 0.45
addMethod · 0.45
as_ptrMethod · 0.45

Tested by 7

test_mutable_resizeFunction · 0.36
test_truncate_with_poolFunction · 0.36
test_resize_with_poolFunction · 0.36
test_sort_run_innerFunction · 0.36
test_run_array_unsliceFunction · 0.36