Skip to main content

locate_segment

Function locate_segment 

pub(crate) fn locate_segment(taus: &[f64], tau: f64, fallback: usize) -> usize
Expand description

The index of the first pillar year fraction at or past tau, or fallback when tau lies beyond the last pillar — the segment locate every piecewise family shares.

Binary rather than linear: the pillar year fractions are strictly increasing by construction, and this sits on the hot path of every curve read. Exactly taus.iter().position(|t| *t >= tau).unwrap_or(fallback), once, instead of that scan pasted per family.