MCPcopy Create free account
hub / github.com/SoftbearStudios/bitcode / populate

Method populate

src/f32.rs:91–100  ·  view source on GitHub ↗
(&mut self, input: &mut &'a [u8], length: usize)

Source from the content-addressed store, hash-verified

89
90impl<'a> View<'a> for F32Decoder<'a> {
91 fn populate(&mut self, input: &mut &'a [u8], length: usize) -> Result<()> {
92 let total: &[u8] = bytemuck::must_cast_slice(consume_byte_arrays::<4>(input, length)?);
93 let (mantissa, sign_exp) = total.split_at(length * 3);
94 let mantissa: &[[u8; 3]] = bytemuck::cast_slice(mantissa);
95 // Equivalent to `mantissa.into()` but satisfies miri when we read extra in decode.
96 self.mantissa =
97 unsafe { FastSlice::from_raw_parts(total.as_ptr() as *const [u8; 3], mantissa.len()) };
98 self.sign_exp = sign_exp.into();
99 Ok(())
100 }
101}
102
103impl<'a> Decoder<'a, f32> for F32Decoder<'a> {

Callers 1

testFunction · 0.45

Calls 2

as_ptrMethod · 0.80
lenMethod · 0.45

Tested by 1

testFunction · 0.36