Commit 32f335ca authored by Hans Fugal's avatar Hans Fugal Committed by Viswanath Sivakumar

avoid std::_Hash_impl

Summary:
Default Yosemite clang has no `std::_Hash_impl`, which is an internal implementation detail anyway.

@davejwatson you might have a different suggestion about how to implement this without that function, or how to test if it exists and do this only if it doesn't. This is probably not the most efficient approach, since it copies the string.

Test Plan:
builds
inspection
fbgs doesn't turn up many results (only recent wangle ssl code really) so I don't think this will be a big perf regression if we just go with it. But if I'm wrong, we can gate it on `#if __APPLE__` or something.

Reviewed By: davejwatson@fb.com

Subscribers: folly-diffs@, fugalh, exa, davejwatson

FB internal diff: D1767052

Signature: t1:1767052:1420738784:e219ebff7aec8682b24c15a03b47077e1559c1ab
parent a1942184
...@@ -57,14 +57,11 @@ struct dn_char_traits : public std::char_traits<char> { ...@@ -57,14 +57,11 @@ struct dn_char_traits : public std::char_traits<char> {
typedef std::basic_string<char, dn_char_traits> DNString; typedef std::basic_string<char, dn_char_traits> DNString;
struct DNStringHash : public std::hash<std::string> { struct DNStringHash : public std::hash<std::string> {
size_t operator()(const DNString& s) const noexcept { size_t operator()(const DNString& s1) const noexcept {
size_t h = static_cast<size_t>(0xc70f6907UL); std::string s2(s1.data(), s1.size());
const char* d = s.data(); for (char& c : s2)
for (size_t i = 0; i < s.length(); ++i) { c = ::tolower(c);
char a = ::tolower(*d++); return std::hash<std::string>()(s2);
h = std::_Hash_impl::hash(&a, sizeof(a), h);
}
return h;
} }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment