mirror of
https://github.com/YosysHQ/yosys
synced 2025-09-12 04:31:29 +00:00
Hash strings 8 bytes at a time
This commit is contained in:
parent
c2ad2a407a
commit
652190bd50
1 changed files with 11 additions and 2 deletions
|
@ -168,8 +168,17 @@ struct hash_ops {
|
||||||
} else if constexpr (std::is_pointer_v<T>) {
|
} else if constexpr (std::is_pointer_v<T>) {
|
||||||
return hash_ops<uintptr_t>::hash_into((uintptr_t) a, h);
|
return hash_ops<uintptr_t>::hash_into((uintptr_t) a, h);
|
||||||
} else if constexpr (std::is_same_v<T, std::string>) {
|
} else if constexpr (std::is_same_v<T, std::string>) {
|
||||||
for (auto c : a)
|
int size = a.size();
|
||||||
h.hash32(c);
|
int i = 0;
|
||||||
|
while (i + 8 < size) {
|
||||||
|
uint64_t v;
|
||||||
|
memcpy(&v, a.data() + i, 8);
|
||||||
|
h.hash64(v);
|
||||||
|
i += 8;
|
||||||
|
}
|
||||||
|
uint64_t v = 0;
|
||||||
|
memcpy(&v, a.data() + i, size - i);
|
||||||
|
h.hash64(v);
|
||||||
return h;
|
return h;
|
||||||
} else {
|
} else {
|
||||||
return a.hash_into(h);
|
return a.hash_into(h);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue