mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-20 23:29:12 +01:00
optimization: migrate SipHashUint256 to PresaltedSipHasher
Replaces standalone `SipHashUint256` with an `operator()` overload in `PresaltedSipHasher`. Updates all hasher classes (`SaltedUint256Hasher`, `SaltedTxidHasher`, `SaltedWtxidHasher`) to use `PresaltedSipHasher` internally, enabling the same constant-state caching optimization while keeping behavior unchanged. Benchmark was also adjusted to cache the salting part.
This commit is contained in:
@@ -96,16 +96,11 @@ uint64_t CSipHasher::Finalize() const
|
||||
return v0 ^ v1 ^ v2 ^ v3;
|
||||
}
|
||||
|
||||
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256& val)
|
||||
uint64_t PresaltedSipHasher::operator()(const uint256& val) const noexcept
|
||||
{
|
||||
/* Specialized implementation for efficiency */
|
||||
uint64_t v0 = v[0], v1 = v[1], v2 = v[2], v3 = v[3];
|
||||
uint64_t d = val.GetUint64(0);
|
||||
|
||||
// TODO moved in followup commit
|
||||
uint64_t v0 = CSipHasher::C0 ^ k0;
|
||||
uint64_t v1 = CSipHasher::C1 ^ k1;
|
||||
uint64_t v2 = CSipHasher::C2 ^ k0;
|
||||
uint64_t v3 = CSipHasher::C3 ^ k1 ^ d;
|
||||
v3 ^= d;
|
||||
|
||||
SIPROUND;
|
||||
SIPROUND;
|
||||
|
||||
Reference in New Issue
Block a user