Improve RippleLineCache hashing

This commit is contained in:
Nik Bougalis
2015-01-16 15:30:30 -08:00
committed by Vinnie Falco
parent 53a16f354f
commit abc4fb81b1
2 changed files with 9 additions and 20 deletions

View File

@@ -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);

View File

@@ -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