MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / from_slice

Method from_slice

cranelift/entity/src/list.rs:277–291  ·  view source on GitHub ↗

Create a new list with the contents initialized from a slice.

(slice: &[T], pool: &mut ListPool<T>)

Source from the content-addressed store, hash-verified

275
276 /// Create a new list with the contents initialized from a slice.
277 pub fn from_slice(slice: &[T], pool: &mut ListPool<T>) -> Self {
278 let len = slice.len();
279 if len == 0 {
280 return Self::new();
281 }
282
283 let block = pool.alloc(sclass_for_length(len));
284 pool.data[block] = T::new(len);
285 pool.data[block + 1..=block + len].copy_from_slice(slice);
286
287 Self {
288 index: (block + 1) as u32,
289 unused: PhantomData,
290 }
291 }
292
293 /// Returns `true` if the list has a length of 0.
294 pub fn is_empty(&self) -> bool {

Callers

nothing calls this directly

Calls 5

sclass_for_lengthFunction · 0.85
newFunction · 0.50
lenMethod · 0.45
allocMethod · 0.45
copy_from_sliceMethod · 0.45

Tested by

no test coverage detected