diff --git a/source/blender/blenlib/BLI_compute_context.hh b/source/blender/blenlib/BLI_compute_context.hh index ecf266479c7..4085139534e 100644 --- a/source/blender/blenlib/BLI_compute_context.hh +++ b/source/blender/blenlib/BLI_compute_context.hh @@ -47,7 +47,6 @@ namespace blender { * have enough bits to make collisions practically impossible. */ struct ComputeContextHash { - static constexpr int64_t HashSizeInBytes = 16; uint64_t v1 = 0; uint64_t v2 = 0; @@ -63,8 +62,6 @@ struct ComputeContextHash { friend std::ostream &operator<<(std::ostream &stream, const ComputeContextHash &hash); }; -static_assert(sizeof(ComputeContextHash) == ComputeContextHash::HashSizeInBytes); - /** * Identifies the context in which a computation happens. This context can be used to identify * values logged during the computation. For more details, see the comment at the top of the file. diff --git a/source/blender/blenlib/intern/compute_context.cc b/source/blender/blenlib/intern/compute_context.cc index 3b058082896..680512018c2 100644 --- a/source/blender/blenlib/intern/compute_context.cc +++ b/source/blender/blenlib/intern/compute_context.cc @@ -11,12 +11,14 @@ namespace blender { void ComputeContextHash::mix_in(const void *data, int64_t len) { - DynamicStackBuffer<> buffer_owner(HashSizeInBytes + len, 8); + const int64_t hash_size = sizeof(ComputeContextHash); + const int64_t buffer_len = hash_size + len; + DynamicStackBuffer<> buffer_owner(buffer_len, 8); char *buffer = static_cast(buffer_owner.buffer()); - memcpy(buffer, this, HashSizeInBytes); - memcpy(buffer + HashSizeInBytes, data, len); + memcpy(buffer, this, hash_size); + memcpy(buffer + hash_size, data, len); - const XXH128_hash_t hash = XXH3_128bits(buffer, len); + const XXH128_hash_t hash = XXH3_128bits(buffer, buffer_len); memcpy(this, &hash, sizeof(hash)); static_assert(sizeof(ComputeContextHash) == sizeof(hash)); }