Skip to content

Commit e45cea0

Browse files
authored
Merge pull request #1443 from evoskuil/master
Use constexpr.
2 parents 03f9790 + 746ffe2 commit e45cea0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

include/bitcoin/system/hash/siphash.hpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <tuple>
2626
#include <bitcoin/system/data/data.hpp>
2727
#include <bitcoin/system/define.hpp>
28+
#include <bitcoin/system/endian/endian.hpp>
2829
#include <bitcoin/system/hash/functions.hpp>
2930

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

40-
BC_API siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT;
41+
constexpr siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT
42+
{
43+
const auto part = split(hash);
44+
const auto hi = from_little_endian(part.first);
45+
const auto lo = from_little_endian(part.second);
46+
return std::make_tuple(hi, lo);
47+
}
4148

4249
} // namespace system
4350
} // namespace libbitcoin

src/hash/siphash.cpp

-9
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,5 @@ uint64_t siphash(const half_hash& hash,
110110
return siphash(to_siphash_key(hash), message);
111111
}
112112

113-
// TODO: constexpr
114-
siphash_key to_siphash_key(const half_hash& hash) NOEXCEPT
115-
{
116-
const auto part = split(hash);
117-
const auto hi = from_little_endian(part.first);
118-
const auto lo = from_little_endian(part.second);
119-
return std::make_tuple(hi, lo);
120-
}
121-
122113
} // namespace system
123114
} // namespace libbitcoin

0 commit comments

Comments
 (0)