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

Method remove_last

cranelift/entity/src/list.rs:548–565  ·  view source on GitHub ↗

Removes the last element from the list.

(&mut self, len: usize, pool: &mut ListPool<T>)

Source from the content-addressed store, hash-verified

546
547 /// Removes the last element from the list.
548 fn remove_last(&mut self, len: usize, pool: &mut ListPool<T>) {
549 // Check if we deleted the last element.
550 if len == 1 {
551 self.clear(pool);
552 return;
553 }
554
555 // Do we need to reallocate to a smaller size class?
556 let mut block = self.index as usize - 1;
557 if is_sclass_min_length(len) {
558 let sclass = sclass_for_length(len);
559 block = pool.realloc(block, sclass, sclass - 1, len);
560 self.index = (block + 1) as u32;
561 }
562
563 // Finally adjust the length.
564 pool.data[block] = T::new(len - 1);
565 }
566
567 /// Removes the element at position `index` from the list. Potentially linear complexity.
568 pub fn remove(&mut self, index: usize, pool: &mut ListPool<T>) {

Callers 2

removeMethod · 0.80
swap_removeMethod · 0.80

Calls 5

is_sclass_min_lengthFunction · 0.85
sclass_for_lengthFunction · 0.85
newFunction · 0.50
clearMethod · 0.45
reallocMethod · 0.45

Tested by

no test coverage detected