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

Method try_inner_insert

cranelift/bforest/src/node.rs:167–189  ·  view source on GitHub ↗

Try to insert `(key, node)` at key-position `index` in an inner node. This means that `key` is inserted at `keys[i]` and `node` is inserted at `tree[i + 1]`. If the node is full, this leaves the node unchanged and returns false.

(&mut self, index: usize, key: F::Key, node: Node)

Source from the content-addressed store, hash-verified

165 /// This means that `key` is inserted at `keys[i]` and `node` is inserted at `tree[i + 1]`.
166 /// If the node is full, this leaves the node unchanged and returns false.
167 pub fn try_inner_insert(&mut self, index: usize, key: F::Key, node: Node) -> bool {
168 match *self {
169 Self::Inner {
170 ref mut size,
171 ref mut keys,
172 ref mut tree,
173 } => {
174 let sz = usize::from(*size);
175 debug_assert!(sz <= keys.len());
176 debug_assert!(index <= sz, "Can't insert at {index} with {sz} keys");
177
178 if let Some(ks) = keys.get_mut(0..=sz) {
179 *size = (sz + 1) as u8;
180 slice_insert(ks, index, key);
181 slice_insert(&mut tree[1..=sz + 1], index, node);
182 true
183 } else {
184 false
185 }
186 }
187 _ => panic!("Expected inner node"),
188 }
189 }
190
191 /// Try to insert `key, value` at `index` in a leaf node, but fail and return false if the node
192 /// is full.

Callers 1

split_and_insertMethod · 0.80

Calls 3

fromFunction · 0.85
slice_insertFunction · 0.85
get_mutMethod · 0.45

Tested by

no test coverage detected