Skip to content

Commit 4d01833

Browse files
committed
[perf] more small string map stuff
1 parent 82ba44f commit 4d01833

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/base/small_string_map.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ small_string_map::lookup(const string_fragment& in)
3838
return std::nullopt;
3939
}
4040

41-
alignas(8) char in_key[MAX_KEY_SIZE]{};
42-
memcpy(in_key, in.data(), in.length());
43-
4441
auto index = this->ssm_start_index;
4542
for (int lpc = 0; lpc < MAP_SIZE; ++lpc) {
46-
if (memcmp(&this->ssm_keys[index * MAX_KEY_SIZE], in_key, MAX_KEY_SIZE)
47-
== 0)
43+
if (memcmp(
44+
&this->ssm_keys[index * MAX_KEY_SIZE], in.data(), in.length())
45+
== 0
46+
&& (in.length() == MAX_KEY_SIZE
47+
|| this->ssm_keys[index * MAX_KEY_SIZE + in.length()] == '\0'))
4848
{
4949
this->ssm_start_index = index;
50-
return index;
50+
return this->ssm_values[index];
5151
}
5252
index = (index + 1) % MAP_SIZE;
5353
}

0 commit comments

Comments
 (0)