From 74b8ced1eee373ada8554ddbcb0e8a1bd8b7c574 Mon Sep 17 00:00:00 2001 From: Sebastian Vater Date: Thu, 24 Jul 2025 15:55:42 +0200 Subject: Made fast hashing a little bit more readable and fixed address increment for next hash data value (should be 8 bytes instead of 1). --- src/server/iscsi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/server/iscsi.c') diff --git a/src/server/iscsi.c b/src/server/iscsi.c index 925e4e8..c5f796d 100644 --- a/src/server/iscsi.c +++ b/src/server/iscsi.c @@ -185,12 +185,13 @@ static int iscsi_hashmap_resize(iscsi_hashmap *map) */ static inline uint32_t iscsi_hashmap_hash_data(const uint8_t *data, const size_t len) { + const uint64_t *hash_data = (const uint64_t *) data; size_t num_blocks = iscsi_align(len, ISCSI_HASHMAP_KEY_ALIGN) >> ISCSI_HASHMAP_KEY_ALIGN_SHIFT; uint64_t hash = ISCSI_HASHMAP_HASH_INITIAL; do { - hash ^= *(uint64_t *) data++; // Hash 8 bytes of data at once - hash *= ISCSI_HASHMAP_HASH_XOR; + hash ^= *hash_data++; + hash *= ISCSI_HASHMAP_HASH_MUL; } while ( --num_blocks > 0UL ); return (uint32_t) (hash ^ hash >> 32ULL); -- cgit v1.2.3-55-g7522