From 21bfc043f0984e2358327d983e130384f575c45c Mon Sep 17 00:00:00 2001 From: Wunkolo Date: Sat, 2 Mar 2024 10:47:33 -0800 Subject: [PATCH] Common/Hash: Add `ComputeHash64` `std::span` interface --- src/common/hash.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/common/hash.h b/src/common/hash.h index 1a222b22e..9fb21775a 100644 --- a/src/common/hash.h +++ b/src/common/hash.h @@ -6,6 +6,7 @@ #include #include +#include #include "common/cityhash.h" #include "common/common_types.h" @@ -21,6 +22,15 @@ static inline u64 ComputeHash64(const void* data, std::size_t len) noexcept { return CityHash64(static_cast(data), len); } +/** + * Computes a 64-bit hash over the specified block of data + * @param data Block of data to compute hash over + * @returns 64-bit hash value that was computed over the data block + */ +static inline u64 ComputeHash64(std::span data) noexcept { + return ComputeHash64(data.data(), data.size()); +} + /** * Computes a 64-bit hash of a struct. In addition to being trivially copyable, it is also critical * that either the struct includes no padding, or that any padding is initialized to a known value