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

Method inner_remove

cranelift/bforest/src/node.rs:309–329  ·  view source on GitHub ↗

Remove the sub-tree at `index` from this inner node. Note that `index` refers to a sub-tree entry and not a key entry as it does for `try_inner_insert()`. It is possible to remove the first sub-tree (which can't be inserted by `try_inner_insert()`). Return an indication of the node's health (i.e. below half capacity).

(&mut self, index: usize)

Source from the content-addressed store, hash-verified

307 ///
308 /// Return an indication of the node's health (i.e. below half capacity).
309 pub fn inner_remove(&mut self, index: usize) -> Removed {
310 match *self {
311 Self::Inner {
312 ref mut size,
313 ref mut keys,
314 ref mut tree,
315 } => {
316 let ents = usize::from(*size) + 1;
317 debug_assert!(ents <= tree.len());
318 debug_assert!(index < ents);
319 // Leave an invalid 0xff size when node becomes empty.
320 *size = ents.wrapping_sub(2) as u8;
321 if ents > 1 {
322 slice_shift(&mut keys[index.saturating_sub(1)..ents - 1], 1);
323 }
324 slice_shift(&mut tree[index..ents], 1);
325 Removed::new(index, ents - 1, tree.len())
326 }
327 _ => panic!("Expected inner node"),
328 }
329 }
330
331 /// Remove the key-value pair at `index` from this leaf node.
332 ///

Callers 1

empty_nodeMethod · 0.80

Calls 5

fromFunction · 0.85
slice_shiftFunction · 0.85
saturating_subMethod · 0.80
newFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected