Skip to main content

should_split

Function should_split 

Source
pub fn should_split(len: usize, item_bytes: usize) -> bool
Expand description

Whether a loop of the given shape is worth splitting at all.

The iterator adapters express this same policy without a branch, so prefer them. Reach for this only where the two paths differ in more than how the work is divided.

An in-place pass that rewrites its buffer as it walks it is the usual case.

The answer moves with the pool, so both arms run somewhere. They must agree on every input, bit for bit, and a test has to pin that directly. Growing a fixture until the host happens to split checks one arm on one machine.

ยงArguments

  • len - total items the loop covers
  • item_bytes - bytes one item moves: every element read, plus every element written