| 246 | } |
| 247 | |
| 248 | static bool EntryKeyEquals(std::string_view key, const Entry& entry) { |
| 249 | if (key.size() >= KeySize) |
| 250 | return false; |
| 251 | |
| 252 | // Test for a NUL terminator and early out if it's absent. |
| 253 | if (entry.key[key.size()] != '\0') |
| 254 | return false; |
| 255 | |
| 256 | // As there's a NUL terminator at the right position in the entries |
| 257 | // string, strncmp can do the rest. |
| 258 | return strncmp(key.data(), entry.key, key.size()) == 0; |
| 259 | } |
| 260 | |
| 261 | const Entry* GetConstEntryForKey(std::string_view key) const { |
| 262 | for (size_t i = 0; i < num_entries; ++i) { |