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

Method decode

src/length.rs:198–219  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

196impl<'a> Decoder<'a, usize> for LengthDecoder<'a> {
197 #[inline(always)]
198 fn decode(&mut self) -> usize {
199 let length = unsafe {
200 let v = self.small.mut_slice().next_unchecked();
201
202 if v < 255 {
203 v as usize
204 } else {
205 #[cold]
206 unsafe fn cold(large: &mut IntDecoder<'_, usize>) -> usize {
207 large.decode()
208 }
209 cold(&mut self.large)
210 }
211 };
212
213 // Allows some checks in Vec::with_capacity to be removed if lto = true.
214 // Safety: sum < HUGE_LEN is checked in populate so all elements have to be < HUGE_LEN.
215 if length as u64 >= HUGE_LEN {
216 unsafe { std::hint::unreachable_unchecked() }
217 }
218 length
219 }
220}
221
222#[cfg(test)]

Callers 3

any_greater_thanMethod · 0.45
populateMethod · 0.45
coldMethod · 0.45

Calls 3

coldFunction · 0.85
next_uncheckedMethod · 0.80
mut_sliceMethod · 0.80

Tested by

no test coverage detected