From 9eb0c2964cadcdd5de74c8992594ea9c2631995d Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Tue, 7 Jul 2015 12:22:50 -0700 Subject: [PATCH] Pass a reference in SHAMap::compare --- .../app/ledger/impl/LedgerConsensusImp.cpp | 2 +- src/ripple/shamap/SHAMap.h | 2 +- src/ripple/shamap/impl/SHAMapDelta.cpp | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp index ab265836d..f665640e6 100644 --- a/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp +++ b/src/ripple/app/ledger/impl/LedgerConsensusImp.cpp @@ -1202,7 +1202,7 @@ void LedgerConsensusImp::createDisputes ( WriteLog (lsDEBUG, LedgerConsensus) << "createDisputes " << m1->getHash() << " to " << m2->getHash(); SHAMap::Delta differences; - m1->compare (m2, differences, 16384); + m1->compare (*m2, differences, 16384); int dc = 0; // for each difference between the transactions diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index 6b3457934..78a0e263e 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -204,7 +204,7 @@ public: // caution: otherMap must be accessed only by this function // return value: true=successfully completed, false=too different - bool compare (std::shared_ptr const& otherMap, + bool compare (SHAMap const& otherMap, Delta& differences, int maxCount) const; int flushDirty (NodeObjectType t, std::uint32_t seq); diff --git a/src/ripple/shamap/impl/SHAMapDelta.cpp b/src/ripple/shamap/impl/SHAMapDelta.cpp index 517eae930..8a5cfe20f 100644 --- a/src/ripple/shamap/impl/SHAMapDelta.cpp +++ b/src/ripple/shamap/impl/SHAMapDelta.cpp @@ -113,7 +113,7 @@ bool SHAMap::walkBranch (SHAMapAbstractNode* node, } bool -SHAMap::compare (std::shared_ptr const& otherMap, +SHAMap::compare (SHAMap const& otherMap, Delta& differences, int maxCount) const { // compare two hash trees, add up to maxCount differences to the difference table @@ -121,15 +121,15 @@ SHAMap::compare (std::shared_ptr const& otherMap, // throws on corrupt tables or missing nodes // CAUTION: otherMap is not locked and must be immutable - assert (isValid () && otherMap && otherMap->isValid ()); + assert (isValid () && otherMap.isValid ()); - if (getHash () == otherMap->getHash ()) + if (getHash () == otherMap.getHash ()) return true; using StackEntry = std::pair ; std::stack > nodeStack; // track nodes we've pushed - nodeStack.push ({root_.get(), otherMap->root_.get()}); + nodeStack.push ({root_.get(), otherMap.root_.get()}); while (!nodeStack.empty ()) { SHAMapAbstractNode* ourNode = nodeStack.top().first; @@ -184,7 +184,7 @@ SHAMap::compare (std::shared_ptr const& otherMap, { auto ours = static_cast(ourNode); auto other = static_cast(otherNode); - if (!otherMap->walkBranch (other, ours->peekItem (), + if (!otherMap.walkBranch (other, ours->peekItem (), false, differences, maxCount)) return false; } @@ -208,15 +208,15 @@ SHAMap::compare (std::shared_ptr const& otherMap, { // The other tree has a branch, we do not SHAMapAbstractNode* iNode = - otherMap->descendThrow(other, i); - if (!otherMap->walkBranch (iNode, + otherMap.descendThrow(other, i); + if (!otherMap.walkBranch (iNode, std::shared_ptr(), false, differences, maxCount)) return false; } else // The two trees have different non-empty branches nodeStack.push ({descendThrow (ours, i), - otherMap->descendThrow (other, i)}); + otherMap.descendThrow (other, i)}); } } else