REAL
Regular Expression Algorithmic Library — constexpr C++20 regex
Loading...
Searching...
No Matches
real::detail::anchored_walk_bill Struct Reference

Tells when the anchored walks from candidates should give way to one forward pass and one reverse, from what the walks that found no match cost against the distance crossed. More...

#include <pike.hpp>

Public Member Functions

constexpr bool overspent (std::size_t length, std::size_t crossed)
 Bills one walk that found no match, and tells whether the walks should give way.
 

Public Attributes

std::size_t walks {0}
 Walks that found no match.
 
std::size_t read {0}
 Bytes those walks read.
 

Static Public Attributes

static constexpr std::size_t per_walk {16}
 One walk that found nothing, doubled with the rest.
 
static constexpr std::size_t per_walk_byte {2}
 One byte such a walk read.
 
static constexpr std::size_t per_pass_byte {3}
 One byte crossed: the bound of 1.5, doubled.
 
static constexpr std::size_t slack {64}
 About four walks before any verdict: a batch of spans starts a fresh bill, and the gap each side is wide.
 

Detailed Description

Tells when the anchored walks from candidates should give way to one forward pass and one reverse, from what the walks that found no match cost against the distance crossed.

A failing walk inside a run of candidate bytes rereads the run the previous one crossed. Score: 8 * failed walks + bytes read, per byte crossed. Over 20 pattern/subject pairs the walks won at <= 0.43 and lost (up to 6x) at >= 4.65, nothing between; the bound sits at 1.5. Namespace-scoped so its verdicts are tested without a search.

Member Function Documentation

◆ overspent()

constexpr bool real::detail::anchored_walk_bill::overspent ( std::size_t  length,
std::size_t  crossed 
)
inlineconstexpr

Bills one walk that found no match, and tells whether the walks should give way.

Parameters
[in]lengthBytes the walk read.
[in]crossedBytes from where the walks began to the walk's candidate.
Returns
True once the single pass would clearly cost less.

The documentation for this struct was generated from the following file: