mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-22 14:50:54 +00:00
fix: Use hashmap for quicker lookup in assembleAdd
This commit is contained in:
committed by
Ayaz Salikhov
parent
d569f7db9e
commit
846369cbe7
@@ -51,6 +51,12 @@ STPathElement::getHash(STPathElement const& element)
|
||||
return (hashAccount ^ hashCurrency ^ hashIssuer);
|
||||
}
|
||||
|
||||
[[nodiscard]] size_t
|
||||
STPathElement::getHash() const
|
||||
{
|
||||
return STPathElement::getHash(*this);
|
||||
}
|
||||
|
||||
STPathSet::STPathSet(SerialIter& sit, SField const& name) : STBase(name)
|
||||
{
|
||||
std::vector<STPathElement> path;
|
||||
@@ -126,21 +132,15 @@ STPathSet::move(std::size_t n, void* buf)
|
||||
bool
|
||||
STPathSet::assembleAdd(STPath const& base, STPathElement const& tail)
|
||||
{ // assemble base+tail and add it to the set if it's not a duplicate
|
||||
value_.push_back(base);
|
||||
STPath combined = base;
|
||||
combined.pushBack(tail);
|
||||
|
||||
auto it = value_.rbegin();
|
||||
|
||||
STPath& newPath = *it;
|
||||
newPath.pushBack(tail);
|
||||
|
||||
while (++it != value_.rend())
|
||||
if (!seenHashes_.insert(combined).second)
|
||||
{
|
||||
if (*it == newPath)
|
||||
{
|
||||
value_.pop_back();
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
value_.push_back(std::move(combined));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user