File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -109,6 +109,16 @@ static TRANSFORM_STEP_CACHE: [OnceLock<TransformStep>; 8] = [
109109 OnceLock :: new ( ) ,
110110] ;
111111
112+ /// Returns the cached [`TransformStep`] for a single-bit [`ProcessType`] flag.
113+ ///
114+ /// The step is lazily initialized on first access via [`OnceLock`] and reused
115+ /// for all subsequent calls with the same flag.
116+ ///
117+ /// # Panics
118+ ///
119+ /// In debug builds, panics if `process_type_bit` is not a single-bit flag
120+ /// (i.e., not a power of two) or exceeds the cache size. Callers must iterate
121+ /// [`ProcessType`] to extract individual bits before calling this function.
112122pub ( crate ) fn get_transform_step ( process_type_bit : ProcessType ) -> & ' static TransformStep {
113123 debug_assert ! (
114124 process_type_bit. bits( ) . is_power_of_two( ) || process_type_bit == ProcessType :: None ,
Original file line number Diff line number Diff line change @@ -456,6 +456,12 @@ impl CharwiseMatcherExt for CharwiseMatcher {
456456/// full pattern set so that non-ASCII haystacks benefit from character-granularity
457457/// scanning (~1.6–1.9× faster on CJK text vs bytewise).
458458///
459+ /// # Panics
460+ ///
461+ /// Panics if the bytewise automaton build thread panics internally. This should
462+ /// not occur under normal operation — it indicates a bug in the underlying
463+ /// `daachorse` or `aho-corasick` builder.
464+ ///
459465/// # Errors
460466///
461467/// Returns [`MatcherError`] if the `daachorse` or `aho-corasick` automaton builders
Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ pub(super) struct PatternEntry {
7676 pub ( super ) boundary : u8 ,
7777 /// Number of positive (AND) segments in the owning rule.
7878 ///
79- /// Duplicated from [`RuleHot::and_count`](super:: rule::RuleHot::and_count) so that
79+ /// Duplicated from the rule's AND-segment count so that
8080 /// [`RuleSet::process_entry`](super::rule::RuleSet::process_entry) can initialize
8181 /// per-rule state without loading the `RuleHot` struct (avoiding a cache miss on
8282 /// the 400KB+ hot array). Fits in the existing struct padding (9→10 bytes, still
Original file line number Diff line number Diff line change @@ -269,6 +269,12 @@ impl RuleSet {
269269 /// Init logic is inlined rather than calling `ScanState::init_rule` so that the
270270 /// `&mut WordState` reference obtained at the start of each arm survives across the
271271 /// init — eliminating a second `word_states` lookup per call.
272+ ///
273+ /// # Panics
274+ ///
275+ /// In debug builds, panics if `entry.rule_idx` is out of bounds for the
276+ /// rule arrays. This invariant is guaranteed by construction in
277+ /// [`SimpleMatcher::new`](super::SimpleMatcher::new).
272278 #[ inline( always) ]
273279 pub ( super ) fn process_entry (
274280 & self ,
Original file line number Diff line number Diff line change @@ -198,6 +198,12 @@ impl SimpleMatcher {
198198 }
199199
200200 /// Unified tree walk that transforms, scans, and evaluates rules in a single pass.
201+ ///
202+ /// # Panics
203+ ///
204+ /// Panics if a non-root node in the transform trie lacks a cached
205+ /// [`TransformStep`]. This is a construction invariant maintained by
206+ /// [`build_process_type_tree`](crate::process::graph::build_process_type_tree).
201207 #[ inline]
202208 pub ( super ) fn walk_and_scan < ' a > (
203209 & ' a self ,
Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ pub(super) struct WordState {
6464 pub ( super ) satisfied_mask : u64 ,
6565 /// Remaining AND segments still needed before the rule can fire.
6666 ///
67- /// Initialized to [`RuleHot ::and_count`](super::rule::RuleHot ::and_count) and
67+ /// Initialized to [`PatternEntry ::and_count`](super::pattern::PatternEntry ::and_count) and
6868 /// decremented as segments are satisfied. The rule becomes positive when this
6969 /// reaches zero.
7070 pub ( super ) remaining_and : u16 ,
You can’t perform that action at this time.
0 commit comments