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

Function split_pos

cranelift/bforest/src/node.rs:473–480  ·  view source on GitHub ↗

Find the right split position for halving a full node with `len` entries to recover from a failed insertion at `ins`. If `len` is even, we should split straight down the middle regardless of `len`. If `len` is odd, we should split the node such that the two halves are the same size after the insertion is retried.

(len: usize, ins: usize)

Source from the content-addressed store, hash-verified

471/// If `len` is odd, we should split the node such that the two halves are the same size after the
472/// insertion is retried.
473fn split_pos(len: usize, ins: usize) -> usize {
474 // Anticipate `len` being a compile time constant, so this all folds away when `len` is even.
475 if ins <= len / 2 {
476 len / 2
477 } else {
478 (len + 1) / 2
479 }
480}
481
482/// The result of splitting off the second half of a node.
483pub(super) struct SplitOff<F: Forest> {

Callers 1

splitMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected