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

Method decode

src/f32.rs:105–115  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

103impl<'a> Decoder<'a, f32> for F32Decoder<'a> {
104 #[inline(always)]
105 fn decode(&mut self) -> f32 {
106 let mantissa_ptr = unsafe { self.mantissa.next_unchecked_as_ptr() };
107
108 // Loading 4 bytes instead of 3 is 30% faster, so we read 1 extra byte after mantissa_ptr.
109 // Safety: The extra byte is within bounds because sign_exp comes after mantissa.
110 let mantissa_extended = unsafe { *(mantissa_ptr as *const [u8; 4]) };
111 let mantissa = u32::from_le_bytes(mantissa_extended) & 0xFF_FF_FF;
112
113 let sign_exp = unsafe { self.sign_exp.next_unchecked() };
114 f32::from_bits(mantissa | ((sign_exp as u32) << 24))
115 }
116}
117
118#[cfg(test)]

Callers

nothing calls this directly

Calls 2

next_unchecked_as_ptrMethod · 0.80
next_uncheckedMethod · 0.80

Tested by

no test coverage detected