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

Function with_scratch

src/pack_ints.rs:237–246  ·  view source on GitHub ↗

Scratch space to bridge gap between pack_ints and pack_bytes. In theory, we could avoid this intermediate step, but it would result in a lot of generated code.

(f: impl FnOnce(&mut Vec<u8>) -> T)

Source from the content-addressed store, hash-verified

235// Scratch space to bridge gap between pack_ints and pack_bytes.
236// In theory, we could avoid this intermediate step, but it would result in a lot of generated code.
237fn with_scratch<T>(f: impl FnOnce(&mut Vec<u8>) -> T) -> T {
238 thread_local! {
239 static SCRATCH: std::cell::RefCell<Vec<u8>> = Default::default();
240 }
241 SCRATCH.with(|s| {
242 let s = &mut s.borrow_mut();
243 s.clear();
244 f(s)
245 })
246}
247macro_rules! impl_u8 {
248 () => {
249 fn pack8(v: &mut [Self], out: &mut Vec<u8>) {

Callers

nothing calls this directly

Calls 2

fFunction · 0.85
clearMethod · 0.80

Tested by

no test coverage detected