MCPcopy Create free account
hub / github.com/apache/datafusion / push_bytes_to_mutable_buffer

Function push_bytes_to_mutable_buffer

datafusion/functions/src/strings.rs:605–629  ·  view source on GitHub ↗
(value_buffer: &mut MutableBuffer, bytes: &[u8])

Source from the content-addressed store, hash-verified

603/// the buffer here directly and force inlining.
604#[inline(always)]
605fn push_bytes_to_mutable_buffer(value_buffer: &mut MutableBuffer, bytes: &[u8]) {
606 let n = bytes.len();
607 let old_len = value_buffer.len();
608 value_buffer.reserve(n);
609
610 // SAFETY: we reserved `n` bytes; the source and destination do not alias
611 // because `bytes` was passed in by the caller and `value_buffer` is owned.
612 unsafe {
613 let dst = value_buffer.as_mut_ptr().add(old_len);
614 let src = bytes.as_ptr();
615 match n {
616 0 => {}
617 1 => std::ptr::copy_nonoverlapping(src, dst, 1),
618 2 => std::ptr::copy_nonoverlapping(src, dst, 2),
619 3 => std::ptr::copy_nonoverlapping(src, dst, 3),
620 4 => std::ptr::copy_nonoverlapping(src, dst, 4),
621 5 => std::ptr::copy_nonoverlapping(src, dst, 5),
622 6 => std::ptr::copy_nonoverlapping(src, dst, 6),
623 7 => std::ptr::copy_nonoverlapping(src, dst, 7),
624 8 => std::ptr::copy_nonoverlapping(src, dst, 8),
625 _ => std::ptr::copy_nonoverlapping(src, dst, n),
626 }
627 value_buffer.set_len(old_len + n);
628 }
629}
630
631#[inline(always)]
632fn push_char_to_mutable_buffer(value_buffer: &mut MutableBuffer, c: char) {

Callers 1

write_strMethod · 0.85

Calls 3

reserveMethod · 0.80
lenMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…