getLongestPrefixIndex
Function parameters
Parameters
Static string map optimized for small sets of disparate string keys.
Functions
- StaticStringMap
- Static string map optimized for small sets of disparate string keys.
- defaultEql
- Like `std.mem.eql`, but takes advantage of the fact that the lengths
- eqlAsciiIgnoreCase
- Like `std.ascii.eqlIgnoreCase` but takes advantage of the fact that
- StaticStringMapWithEql
- StaticStringMap, but accepts an equality function (`eql`).
Source
Implementation
pub fn getLongestPrefixIndex(self: Self, str: []const u8) ?usize {
if (self.kvs.len == 0)
return null;
if (str.len < self.min_len)
return null;
var len = @min(self.max_len, str.len);
while (len >= self.min_len) : (len -= 1) {
if (self.getIndex(str[0..len])) |i|
return i;
}
return null;
}