fix: Use hashmap for quicker lookup in assembleAdd

This commit is contained in:
Timothy Banks
2026-07-16 17:16:09 +01:00
committed by Ayaz Salikhov
parent d569f7db9e
commit 846369cbe7
4 changed files with 139 additions and 27 deletions

View File

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