From 652190bd5002800f66db252b9a1714a94e30e1a0 Mon Sep 17 00:00:00 2001 From: Robert O'Callahan Date: Fri, 29 Aug 2025 04:13:23 +0000 Subject: [PATCH] Hash strings 8 bytes at a time --- kernel/hashlib.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/hashlib.h b/kernel/hashlib.h index 9c53e6687..2cff32559 100644 --- a/kernel/hashlib.h +++ b/kernel/hashlib.h @@ -168,8 +168,17 @@ struct hash_ops { } else if constexpr (std::is_pointer_v) { return hash_ops::hash_into((uintptr_t) a, h); } else if constexpr (std::is_same_v) { - for (auto c : a) - h.hash32(c); + int size = a.size(); + 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; } else { return a.hash_into(h);