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> {
typedef std::basic_string<char, dn_char_traits> DNString;
struct DNStringHash : public std::hash<std::string> {
size_t operator()(const DNString& s) const noexcept {
size_t h = static_cast<size_t>(0xc70f6907UL);
const char* d = s.data();
for (size_t i = 0; i < s.length(); ++i) {
char a = ::tolower(*d++);
h = std::_Hash_impl::hash(&a, sizeof(a), h);
}
return h;
size_t operator()(const DNString& s1) const noexcept {
std::string s2(s1.data(), s1.size());
for (char& c : s2)
c = ::tolower(c);
return std::hash<std::string>()(s2);
}
};
......
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