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

Method encode_vectored_max_len

src/length.rs:60–84  ·  view source on GitHub ↗
(
        &mut self,
        i: impl Iterator<Item = T>,
        mut encode: impl FnMut(T),
    )

Source from the content-addressed store, hash-verified

58 /// Skips calling encode for T::len() == 0. Returns `true` if it failed due to a length over `N`.
59 #[inline(always)]
60 pub fn encode_vectored_max_len<T: Len, const N: usize>(
61 &mut self,
62 i: impl Iterator<Item = T>,
63 mut encode: impl FnMut(T),
64 ) -> bool {
65 debug_assert!(N <= 64);
66 let mut ptr = self.small.end_ptr();
67 for t in i {
68 let n = t.len();
69 unsafe {
70 *ptr = n as u8;
71 ptr = ptr.add(1);
72 }
73 if n == 0 {
74 continue;
75 }
76 if n > N {
77 // Don't set end ptr (elements won't be saved).
78 return true;
79 }
80 encode(t);
81 }
82 self.small.set_end_ptr(ptr);
83 false
84 }
85
86 #[inline(always)]
87 pub fn encode_vectored_fallback<T: Len>(

Callers

nothing calls this directly

Calls 4

encodeFunction · 0.85
end_ptrMethod · 0.80
set_end_ptrMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected