mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Improve RippleLineCache hashing
This commit is contained in:
committed by
Vinnie Falco
parent
53a16f354f
commit
abc4fb81b1
@@ -30,7 +30,7 @@ RippleLineCache::RippleLineCache (Ledger::ref l)
|
||||
RippleLineCache::RippleStateVector const&
|
||||
RippleLineCache::getRippleLines (Account const& accountID)
|
||||
{
|
||||
AccountKey key (accountID);
|
||||
AccountKey key (accountID, hasher_ (accountID));
|
||||
|
||||
ScopedLockType sl (mLock);
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ private:
|
||||
typedef std::lock_guard <LockType> ScopedLockType;
|
||||
LockType mLock;
|
||||
|
||||
ripple::hardened_hash<> hasher_;
|
||||
Ledger::pointer mLedger;
|
||||
|
||||
struct AccountKey
|
||||
@@ -58,31 +59,19 @@ private:
|
||||
Account account_;
|
||||
std::size_t hash_value_;
|
||||
|
||||
AccountKey (Account const& account)
|
||||
AccountKey (Account const& account, std::size_t hash)
|
||||
: account_ (account)
|
||||
, hash_value_ (hardened_hash<>{}(account))
|
||||
{
|
||||
, hash_value_ (hash)
|
||||
{ }
|
||||
|
||||
}
|
||||
AccountKey (AccountKey const& other) = default;
|
||||
|
||||
AccountKey (AccountKey const& other)
|
||||
: account_ (other.account_)
|
||||
, hash_value_ (other.hash_value_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AccountKey& operator=(AccountKey const& other)
|
||||
{
|
||||
account_ = other.account_;
|
||||
hash_value_ = other.hash_value_;
|
||||
return *this;
|
||||
}
|
||||
AccountKey&
|
||||
operator=(AccountKey const& other) = default;
|
||||
|
||||
bool operator== (AccountKey const& lhs) const
|
||||
{
|
||||
return hash_value_ == lhs.hash_value_ &&
|
||||
account_ == lhs.account_;
|
||||
return hash_value_ == lhs.hash_value_ && account_ == lhs.account_;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
|
||||
Reference in New Issue
Block a user