(&mut self, len: usize)
| 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> { |
no test coverage detected