mirror of
https://github.com/boostorg/hash2.git
synced 2026-01-19 04:12:12 +00:00
Provide separate named xxh3_128 constructors that match the reference implmentation
This commit is contained in:
@@ -535,11 +535,7 @@ public:
|
||||
seed_ = seed;
|
||||
}
|
||||
|
||||
// XXH3-specific constructor (XXH3_withSecretAndSeed), not part of the concept requirements
|
||||
|
||||
xxh3_128( std::uint64_t seed, void const* p, std::size_t n ): xxh3_128( seed, static_cast<unsigned char const*>( p ), n )
|
||||
{
|
||||
}
|
||||
private: // supporting constructor for the static factory functions
|
||||
|
||||
BOOST_CXX14_CONSTEXPR xxh3_128( std::uint64_t seed, unsigned char const* p, std::size_t n ): seed_( seed )
|
||||
{
|
||||
@@ -604,6 +600,40 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
// XXH3-specific named constructors, matching the reference implementation
|
||||
|
||||
// for completeness only
|
||||
static BOOST_CXX14_CONSTEXPR xxh3_128 withSeed( std::uint64_t seed )
|
||||
{
|
||||
return xxh3_128( seed );
|
||||
}
|
||||
|
||||
static xxh3_128 BOOST_CXX14_CONSTEXPR withSecret( unsigned char const* p, std::size_t n )
|
||||
{
|
||||
return xxh3_128( 0, p, n );
|
||||
}
|
||||
|
||||
static xxh3_128 withSecret( void const* p, std::size_t n )
|
||||
{
|
||||
return withSecret( static_cast<unsigned char const*>( p ), n );
|
||||
}
|
||||
|
||||
static xxh3_128 BOOST_CXX14_CONSTEXPR withSecretAndSeed( unsigned char const* p, std::size_t n, std::uint64_t seed )
|
||||
{
|
||||
xxh3_128 r( seed, p, n );
|
||||
|
||||
r.with_secret_ = false;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
static xxh3_128 withSecretAndSeed( void const* p, std::size_t n, std::uint64_t seed )
|
||||
{
|
||||
return withSecretAndSeed( static_cast<unsigned char const*>( p ), n, seed );
|
||||
}
|
||||
|
||||
void update( void const* p, std::size_t n )
|
||||
{
|
||||
update( static_cast<unsigned char const*>( p ), n );
|
||||
|
||||
@@ -50,12 +50,12 @@ template<class H, class S> typename H::result_type hash( std::vector<unsigned ch
|
||||
|
||||
template<class H> typename H::result_type hash( std::vector<unsigned char> const& s, std::size_t n, unsigned char const* secret, std::size_t secret_len )
|
||||
{
|
||||
H h( 0, secret, secret_len );
|
||||
H h = H::withSecret( secret, secret_len );
|
||||
|
||||
h.update( s.data(), n );
|
||||
auto d = h.result();
|
||||
|
||||
H h2( 0, secret, secret_len );
|
||||
H h2 = H::withSecret( secret, secret_len );
|
||||
|
||||
std::size_t m = n / 3;
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ template<class H> BOOST_CXX14_CONSTEXPR typename H::result_type hash( std::size_
|
||||
|
||||
template<class H> BOOST_CXX14_CONSTEXPR typename H::result_type hash( std::size_t n, unsigned char const* secret, std::size_t secret_len )
|
||||
{
|
||||
H h( 0, secret, secret_len );
|
||||
H h = H::withSecret( secret, secret_len );
|
||||
|
||||
std::size_t m = n / 3;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user