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

Method try_alloc_index

crates/core/src/slab.rs:344–356  ·  view source on GitHub ↗
(&mut self)

Source from the content-addressed store, hash-verified

342
343 #[inline]
344 fn try_alloc_index(&mut self) -> Option<EntryIndex> {
345 self.free.take().or_else(|| {
346 if self.entries.len() < self.entries.capacity() {
347 let index = EntryIndex::new(self.entries.len());
348 self.entries
349 .push(Entry::Free { next_free: None })
350 .expect("have capacity");
351 Some(index)
352 } else {
353 None
354 }
355 })
356 }
357
358 /// Allocate a `T` value within this slab, allocating additional underlying
359 /// storage if there is no available capacity.

Callers 1

try_allocMethod · 0.80

Calls 6

newFunction · 0.50
takeMethod · 0.45
lenMethod · 0.45
capacityMethod · 0.45
expectMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected