Skip to content

Commit d35b8b7

Browse files
authored
Merge pull request #44 from cmazakas/feature/xxh3-cleanup
xxh3 cleanup
2 parents ffe62e1 + e8abd08 commit d35b8b7

File tree

3 files changed

+278
-193
lines changed

3 files changed

+278
-193
lines changed

include/boost/hash2/xxh3.hpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,8 @@ class xxh3_128
537537

538538
private: // supporting constructor for the static factory functions
539539

540-
BOOST_CXX14_CONSTEXPR xxh3_128( std::uint64_t seed, unsigned char const* p, std::size_t n ): seed_( seed )
540+
BOOST_CXX14_CONSTEXPR xxh3_128( std::uint64_t seed, unsigned char const* p, std::size_t n, bool with_secret ): seed_( seed ), with_secret_( with_secret )
541541
{
542-
with_secret_ = true;
543-
544542
if( n < min_secret_len )
545543
{
546544
// this is a precondition violation for XXH3, but we try to do something reasonable
@@ -605,33 +603,29 @@ class xxh3_128
605603
// XXH3-specific named constructors, matching the reference implementation
606604

607605
// for completeness only
608-
static BOOST_CXX14_CONSTEXPR xxh3_128 withSeed( std::uint64_t seed )
606+
static BOOST_CXX14_CONSTEXPR xxh3_128 with_seed( std::uint64_t seed )
609607
{
610608
return xxh3_128( seed );
611609
}
612610

613-
static BOOST_CXX14_CONSTEXPR xxh3_128 withSecret( unsigned char const* p, std::size_t n )
611+
static BOOST_CXX14_CONSTEXPR xxh3_128 with_secret( unsigned char const* p, std::size_t n )
614612
{
615-
return xxh3_128( 0, p, n );
613+
return xxh3_128( 0, p, n, true );
616614
}
617615

618-
static xxh3_128 withSecret( void const* p, std::size_t n )
616+
static xxh3_128 with_secret( void const* p, std::size_t n )
619617
{
620-
return withSecret( static_cast<unsigned char const*>( p ), n );
618+
return with_secret( static_cast<unsigned char const*>( p ), n );
621619
}
622620

623-
static BOOST_CXX14_CONSTEXPR xxh3_128 withSecretAndSeed( unsigned char const* p, std::size_t n, std::uint64_t seed )
621+
static BOOST_CXX14_CONSTEXPR xxh3_128 with_secret_and_seed( unsigned char const* p, std::size_t n, std::uint64_t seed )
624622
{
625-
xxh3_128 r( seed, p, n );
626-
627-
r.with_secret_ = false;
628-
629-
return r;
623+
return xxh3_128( seed, p, n, false );
630624
}
631625

632-
static xxh3_128 withSecretAndSeed( void const* p, std::size_t n, std::uint64_t seed )
626+
static xxh3_128 with_secret_and_seed( void const* p, std::size_t n, std::uint64_t seed )
633627
{
634-
return withSecretAndSeed( static_cast<unsigned char const*>( p ), n, seed );
628+
return with_secret_and_seed( static_cast<unsigned char const*>( p ), n, seed );
635629
}
636630

637631
void update( void const* p, std::size_t n )

0 commit comments

Comments
 (0)