mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 23:45:51 +00:00
Compare commits
1 Commits
Bronek/opt
...
Bronek/pro
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e874c4061e |
@@ -35,22 +35,22 @@ namespace beast {
|
||||
class xxhasher
|
||||
{
|
||||
public:
|
||||
using HashType = std::size_t;
|
||||
using result_type = std::size_t;
|
||||
|
||||
private:
|
||||
// requires 64-bit std::size_t
|
||||
static_assert(sizeof(std::size_t) == 8, "");
|
||||
static_assert(sizeof(std::size_t) == 8, "requires 64-bit std::size_t");
|
||||
|
||||
// Have an internal buffer to avoid the streaming API
|
||||
// A 40-byte buffer should to be big enough for us
|
||||
static constexpr std::size_t INTERNAL_BUFFER_SIZE = 40;
|
||||
// A 64-byte buffer should to be big enough for us
|
||||
static constexpr std::size_t INTERNAL_BUFFER_SIZE = 64;
|
||||
|
||||
alignas(64) std::array<std::uint8_t, INTERNAL_BUFFER_SIZE> buffer_;
|
||||
std::span<std::uint8_t> readBuffer_;
|
||||
std::span<std::uint8_t> writeBuffer_;
|
||||
|
||||
std::optional<XXH64_hash_t> seed_;
|
||||
XXH3_state_t* state_ = nullptr;
|
||||
|
||||
std::array<std::uint8_t, INTERNAL_BUFFER_SIZE> buffer_;
|
||||
std::span<std::uint8_t> readBuffer_;
|
||||
std::span<std::uint8_t> writeBuffer_;
|
||||
|
||||
void
|
||||
resetBuffers()
|
||||
{
|
||||
@@ -106,7 +106,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
HashType
|
||||
result_type
|
||||
retrieveHash()
|
||||
{
|
||||
if (state_)
|
||||
@@ -129,8 +129,6 @@ private:
|
||||
}
|
||||
|
||||
public:
|
||||
using result_type = std::size_t;
|
||||
|
||||
static constexpr auto const endian = boost::endian::order::native;
|
||||
|
||||
xxhasher(xxhasher const&) = delete;
|
||||
@@ -173,7 +171,7 @@ public:
|
||||
}
|
||||
|
||||
explicit
|
||||
operator HashType() noexcept
|
||||
operator result_type() noexcept
|
||||
{
|
||||
return retrieveHash();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 16042857369214894119ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
16042857369214894119ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -50,7 +51,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 14440132435660934800ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
14440132435660934800ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -64,7 +66,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 14440132435660934800ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
14440132435660934800ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -80,7 +83,8 @@ public:
|
||||
}
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 15296278154063476002ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
15296278154063476002ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -96,7 +100,8 @@ public:
|
||||
}
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 17285302196561698791ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
17285302196561698791ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -116,7 +121,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 1865045178324729219ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
1865045178324729219ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -136,7 +142,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 16189862915636005281ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
16189862915636005281ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -153,7 +160,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 15296278154063476002ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
15296278154063476002ULL);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -170,7 +178,8 @@ public:
|
||||
hasher(objectToHash.data(), objectToHash.size());
|
||||
|
||||
BEAST_EXPECT(
|
||||
static_cast<xxhasher::HashType>(hasher) == 17285302196561698791ULL);
|
||||
static_cast<xxhasher::result_type>(hasher) ==
|
||||
17285302196561698791ULL);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
Reference in New Issue
Block a user