MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / longest_symbol_match

Function longest_symbol_match

nodedb-codec/src/fsst.rs:138–146  ·  view source on GitHub ↗

Find the longest symbol matching at position `pos` in `data`. Returns the match length (0 if no match).

(symbols: &[Vec<u8>], data: &[u8], pos: usize)

Source from the content-addressed store, hash-verified

136/// Find the longest symbol matching at position `pos` in `data`.
137/// Returns the match length (0 if no match).
138fn longest_symbol_match(symbols: &[Vec<u8>], data: &[u8], pos: usize) -> usize {
139 let remaining = &data[pos..];
140 for sym in symbols {
141 if remaining.starts_with(sym) {
142 return sym.len();
143 }
144 }
145 0
146}
147
148// ---------------------------------------------------------------------------
149// Public encode / decode API

Callers 1

trainMethod · 0.85

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected