pub struct SpanHistory { /* private fields */ }Expand description
The recent token spans behind the stomach’s boxes: how many tokens the
gullet read for each box the stomach’s CycleGuard records. A box period
alone cannot tell a loop from a long run over data: every point of a pgf
plot[smooth] digests the same content-free boxes (tkz-grapheur’s
11,000-point plot read as a 6-box cycle). A loop repeats the same boxes from
the same input; a run over data repeats them from input of varying length.
So a detected box period is a loop only when the spans repeat too, with a
period that is a multiple of the box period (Self::input_period).
Implementations§
Source§impl SpanHistory
impl SpanHistory
Sourcepub fn push(&mut self, span: usize, salt: u64)
pub fn push(&mut self, span: usize, salt: u64)
Record the span of the newest box, with the register values read for it (take_span_salt): a counter loop
reads the same input each period but a new count, so its spans do not repeat.
Sourcepub fn input_period(&self, box_period: usize) -> Option<usize>
pub fn input_period(&self, box_period: usize) -> Option<usize>
The smallest period, a multiple of box_period up to
MAX_SPAN_PERIOD, with which the recorded spans repeat over the whole
history (at least eight repetitions of it); None when they do not.