Skip to content

Commit

Permalink
Simplify fnv1a_xx(uint64_t). Compilers are smart enough to optimize t…
Browse files Browse the repository at this point in the history
…he final four updates when the seed is known to be a 32 bit value.
  • Loading branch information
pdimov committed Oct 21, 2024
1 parent db1c83b commit 8ea059a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions include/boost/hash2/fnv1a.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,9 @@ template<class T> class fnv1a
{
if( seed )
{
if( seed >> 32 )
{
unsigned char tmp[ 8 ];
detail::write64le( tmp, seed );
update( tmp, 8 );
}
else
{
unsigned char tmp[ 4 ];
detail::write32le( tmp, static_cast<std::uint32_t>( seed ) );
update( tmp, 4 );
}
unsigned char tmp[ 8 ];
detail::write64le( tmp, seed );
update( tmp, 8 );
}
}

Expand Down

0 comments on commit 8ea059a

Please sign in to comment.