File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ --- a/components/misc/strings/algorithm.hpp
2+ +++ b/components/misc/strings/algorithm.hpp
3+ @@ -4,6 +4,7 @@
4+ #include "lower.hpp"
5+
6+ #include <algorithm>
7+ + #include <cstdint>
8+ #include <functional>
9+ #include <string>
10+ #include <string_view>
11+ @@ -88,8 +89,8 @@
12+ constexpr std::size_t operator()(std::string_view str) const
13+ {
14+ // FNV-1a
15+ - std::size_t hash{ 0xcbf29ce484222325ull };
16+ - constexpr std::size_t prime{ 0x00000100000001B3ull };
17+ + std::uint64_t hash{ 0xcbf29ce484222325ull };
18+ + constexpr std::uint64_t prime{ 0x00000100000001B3ull };
19+ for (char c : str)
20+ {
21+ hash ^= static_cast<std::size_t>(toLower(c));
22+ --- a/components/esm/formid.hpp
23+ +++ b/components/esm/formid.hpp
24+ @@ -49,12 +49,12 @@
25+ template <>
26+ struct hash<ESM::FormId>
27+ {
28+ - size_t operator()(const ESM::FormId& formId) const
29+ + uint64_t operator()(const ESM::FormId& formId) const
30+ {
31+ - static_assert(sizeof(ESM::FormId) == sizeof(size_t));
32+ - size_t s;
33+ - memcpy(&s, &formId, sizeof(size_t));
34+ - return hash<size_t>()(s);
35+ + static_assert(sizeof(ESM::FormId) == 8); // 8 uint32_t itmes
36+ + uint64_t s;
37+ + memcpy(&s, &formId, sizeof(ESM::FormId));
38+ + return hash<uint64_t>()(s);
39+ }
40+ };
You can’t perform that action at this time.
0 commit comments