Skip to content

Commit 2113488

Browse files
committed
fixup
Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
1 parent 6c8e616 commit 2113488

3 files changed

Lines changed: 7 additions & 8 deletions

File tree

encodings/fsst/src/dfa/flat_contains.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
//!
1111
//! ## Construction (needle = `"aba"`, symbols = `[0:"ab", 1:"ba"]`)
1212
//!
13-
//! ### Step 1: KMP byte-level transition table
13+
//! ### Step 1: KMP (Knuth–Morris–Pratt) byte-level transition table
14+
//!
15+
//! See: https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm
1416
//!
1517
//! Build a `(state × byte) → state` table using the KMP failure function.
1618
//! States 0..2 track match progress, state 3 is accept (sticky).

encodings/fsst/src/dfa/prefix.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,11 @@ impl FlatPrefixDfa {
7272
let n_states = fail_state + 1;
7373
let sentinel = fail_state + 1;
7474

75-
// Step 1: byte-level transitions
7675
let byte_table = build_prefix_byte_table(prefix, accept_state, fail_state);
7776

78-
// Step 2: symbol-level transitions
7977
let sym_trans =
8078
build_symbol_transitions(symbols, symbol_lengths, &byte_table, n_states, accept_state);
8179

82-
// Step 3: fused table with escape sentinel
8380
let transitions = build_fused_table(
8481
&sym_trans,
8582
symbols.len(),
@@ -125,7 +122,7 @@ impl FlatPrefixDfa {
125122
}
126123
}
127124

128-
/// Build a byte-level transition table for prefix matching (no KMP fallback).
125+
/// Build a byte-level transition table for prefix matching.
129126
///
130127
/// For each state, only the correct next byte advances; everything else goes
131128
/// to the fail state.

fuzz/src/fsst_like.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ struct SmallAlphabetString {
4242
impl SmallAlphabetString {
4343
fn generate(&self, u: &mut Unstructured<'_>) -> arbitrary::Result<String> {
4444
let len: usize = u.int_in_range(0..=self.max_len)?;
45-
Ok((0..len)
46-
.map(|_| u.int_in_range(b'a'..=b'h').expect("cannot make char") as char)
47-
.collect())
45+
(0..len)
46+
.map(|_| Ok(u.int_in_range(b'a'..=b'h')? as char))
47+
.collect()
4848
}
4949
}
5050

0 commit comments

Comments
 (0)