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

Function push_char_to_mutable_buffer

datafusion/functions/src/strings.rs:632–648  ·  view source on GitHub ↗
(value_buffer: &mut MutableBuffer, c: char)

Source from the content-addressed store, hash-verified

630
631#[inline(always)]
632fn push_char_to_mutable_buffer(value_buffer: &mut MutableBuffer, c: char) {
633 let len = c.len_utf8();
634 let old_len = value_buffer.len();
635 value_buffer.reserve(len);
636
637 // SAFETY: we reserved `len` bytes above, write valid UTF-8 into those
638 // bytes, then update the initialized length to include them.
639 unsafe {
640 let dst = value_buffer.as_mut_ptr().add(old_len);
641 if len == 1 {
642 *dst = c as u8;
643 } else {
644 c.encode_utf8(std::slice::from_raw_parts_mut(dst, len));
645 }
646 value_buffer.set_len(old_len + len);
647 }
648}
649
650/// Builder for a [`StringViewArray`].
651///

Callers 1

write_charMethod · 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…