Skip to content

Commit

Permalink
Use constexpr.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Apr 28, 2024
1 parent 03f9790 commit 746ffe2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
9 changes: 8 additions & 1 deletion include/bitcoin/system/hash/siphash.hpp
Expand Up @@ -25,6 +25,7 @@
#include <tuple>
#include <bitcoin/system/data/data.hpp>
#include <bitcoin/system/define.hpp>
#include <bitcoin/system/endian/endian.hpp>
#include <bitcoin/system/hash/functions.hpp>

namespace libbitcoin {
Expand All @@ -37,7 +38,13 @@ BC_API uint64_t siphash(const siphash_key& key,
BC_API uint64_t siphash(const half_hash& hash,
const data_slice& message) NOEXCEPT;

BC_API siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT;
constexpr siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT
{
const auto part = split(hash);
const auto hi = from_little_endian(part.first);
const auto lo = from_little_endian(part.second);
return std::make_tuple(hi, lo);
}

} // namespace system
} // namespace libbitcoin
Expand Down
9 changes: 0 additions & 9 deletions src/hash/siphash.cpp
Expand Up @@ -110,14 +110,5 @@ uint64_t siphash(const half_hash& hash,
return siphash(to_siphash_key(hash), message);
}

// TODO: constexpr
siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT
{
const auto part = split(hash);
const auto hi = from_little_endian(part.first);
const auto lo = from_little_endian(part.second);
return std::make_tuple(hi, lo);
}

} // namespace system
} // namespace libbitcoin

0 comments on commit 746ffe2

Please sign in to comment.