getIndex
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 getIndex(self: Self, str: []const u8) ?usize {
const kvs = self.kvs.*;
if (kvs.len == 0)
return null;
if (str.len < self.min_len or str.len > self.max_len)
return null;
var i = self.len_indexes[str.len];
while (true) {
const key = kvs.keys[i];
if (key.len != str.len)
return null;
if (eql(key, str))
return i;
i += 1;
if (i >= kvs.len)
return null;
}
}