Improve StaticString hashing

In a lot of case the StaticString hash can be computed a compile time,
so we now take advantage of that.

Removed StaticString(const char*) ctor, and replaced it with a
StaticString::make() method.

Fixed a couple wrong uses of the old StaticString(const char*) ctor.
This commit is contained in:
Mathias Agopian
2018-12-12 13:47:28 -08:00
committed by Mathias Agopian
parent d135108763
commit 2d6b43827e
8 changed files with 76 additions and 31 deletions

View File

@@ -361,8 +361,8 @@ Filter filterFromString(const char* rawname) {
{ "MINIMUM", Filter::MINIMUM},
};
string name = rawname;
for (auto& c: name) c = toupper((unsigned char) c);
auto iter = map.find({ name.c_str(), name.size() });
for (auto& c: name) { c = toupper((unsigned char)c); }
auto iter = map.find(StaticString::make(name.c_str(), name.size()));
return iter == map.end() ? Filter::DEFAULT : iter->second;
}