MCPcopy Create free account
hub / github.com/apache/fory / read_utf8_string_unchecked

Method read_utf8_string_unchecked

rust/fory-core/src/buffer.rs:973–986  ·  view source on GitHub ↗
(&mut self, len: usize)

Source from the content-addressed store, hash-verified

971
972 #[inline(always)]
973 pub fn read_utf8_string_unchecked(&mut self, len: usize) -> Result<String, Error> {
974 self.check_bound(len)?;
975 // don't use simd for memory copy, copy_non_overlapping is faster
976 unsafe {
977 let mut vec = Vec::with_capacity(len);
978 let src = self.bf.as_ptr().add(self.cursor);
979 let dst = vec.as_mut_ptr();
980 // Use fastest possible copy - copy_nonoverlapping compiles to memcpy
981 std::ptr::copy_nonoverlapping(src, dst, len);
982 vec.set_len(len);
983 self.move_next(len);
984 Ok(String::from_utf8_unchecked(vec))
985 }
986 }
987
988 #[inline(always)]
989 pub fn read_utf16_string(&mut self, len: usize) -> Result<String, Error> {

Callers 1

fory_read_dataMethod · 0.80

Calls 3

check_boundMethod · 0.80
move_nextMethod · 0.80
addMethod · 0.65

Tested by

no test coverage detected