diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 6ba79cfa2..ff5eb86a6 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -416,7 +416,7 @@ Ledger::setAccepted(NetClock::time_point closeTime, bool Ledger::addSLE (SLE const& sle) { SHAMapItem item (sle.getIndex(), sle.getSerializer()); - return stateMap_->addItem(item, false, false); + return stateMap_->addItem(std::move(item), false, false); } //------------------------------------------------------------------------------ diff --git a/src/ripple/shamap/SHAMap.h b/src/ripple/shamap/SHAMap.h index af59983f2..8c76deccf 100644 --- a/src/ripple/shamap/SHAMap.h +++ b/src/ripple/shamap/SHAMap.h @@ -137,7 +137,6 @@ public: // normal hash access functions bool hasItem (uint256 const& id) const; bool delItem (uint256 const& id); - bool addItem (SHAMapItem const& i, bool isTransaction, bool hasMeta); bool addItem (SHAMapItem&& i, bool isTransaction, bool hasMeta); SHAMapHash getHash () const; @@ -193,12 +192,10 @@ public: int flushDirty (NodeObjectType t, std::uint32_t seq); void walkMap (std::vector& missingNodes, int maxMissing) const; - bool deepCompare (SHAMap & other) const; + bool deepCompare (SHAMap & other) const; // Intended for debug/test only using fetchPackEntry_t = std::pair ; - void visitDifferences(SHAMap* have, std::function) const; - void getFetchPack (SHAMap * have, bool includeLeaves, int max, std::function) const; @@ -212,6 +209,7 @@ private: using DeltaRef = std::pair const&, std::shared_ptr const&>; + void visitDifferences(SHAMap* have, std::function) const; int unshare (); // tree node cache operations diff --git a/src/ripple/shamap/impl/SHAMap.cpp b/src/ripple/shamap/impl/SHAMap.cpp index e24f1ae57..ffd260e8e 100644 --- a/src/ripple/shamap/impl/SHAMap.cpp +++ b/src/ripple/shamap/impl/SHAMap.cpp @@ -755,11 +755,6 @@ SHAMap::addGiveItem (std::shared_ptr const& item, return true; } -bool SHAMap::addItem (const SHAMapItem& i, bool isTransaction, bool hasMetaData) -{ - return addGiveItem(std::make_shared(i), isTransaction, hasMetaData); -} - bool SHAMap::addItem(SHAMapItem&& i, bool isTransaction, bool hasMetaData) { diff --git a/src/ripple/shamap/tests/FetchPack.test.cpp b/src/ripple/shamap/tests/FetchPack.test.cpp index fdf929b77..d74e467a8 100644 --- a/src/ripple/shamap/tests/FetchPack.test.cpp +++ b/src/ripple/shamap/tests/FetchPack.test.cpp @@ -103,7 +103,7 @@ public: { std::shared_ptr item ( make_random_item (r)); - auto const result (t.addItem (*item, false, false)); + auto const result (t.addItem (std::move(*item), false, false)); assert (result); (void) result; } diff --git a/src/ripple/shamap/tests/SHAMap.test.cpp b/src/ripple/shamap/tests/SHAMap.test.cpp index 7d1280079..92e749602 100644 --- a/src/ripple/shamap/tests/SHAMap.test.cpp +++ b/src/ripple/shamap/tests/SHAMap.test.cpp @@ -75,8 +75,8 @@ public: sMap.setUnbacked (); SHAMapItem i1 (h1, IntToVUC (1)), i2 (h2, IntToVUC (2)), i3 (h3, IntToVUC (3)), i4 (h4, IntToVUC (4)), i5 (h5, IntToVUC (5)); - unexpected (!sMap.addItem (i2, true, false), "no add"); - unexpected (!sMap.addItem (i1, true, false), "no add"); + unexpected (!sMap.addItem (SHAMapItem{i2}, true, false), "no add"); + unexpected (!sMap.addItem (SHAMapItem{i1}, true, false), "no add"); auto i = sMap.begin(); auto e = sMap.end(); @@ -85,9 +85,9 @@ public: unexpected (i == e || (*i != i2), "bad traverse"); ++i; unexpected (i != e, "bad traverse"); - sMap.addItem (i4, true, false); + sMap.addItem (SHAMapItem{i4}, true, false); sMap.delItem (i2.key()); - sMap.addItem (i3, true, false); + sMap.addItem (SHAMapItem{i3}, true, false); i = sMap.begin(); e = sMap.end(); unexpected (i == e || (*i != i1), "bad traverse"); @@ -110,6 +110,7 @@ public: unexpected (!sMap.delItem (sMap.begin()->key()), "bad mod"); unexpected (sMap.getHash () == mapHash, "bad snapshot"); unexpected (map2->getHash () != mapHash, "bad snapshot"); + sMap.dump(); if (backed) testcase ("build/tear backed"); @@ -144,7 +145,7 @@ public: for (int i = 0; i < keys.size(); ++i) { SHAMapItem item (keys[i], IntToVUC (i)); - expect (map.addItem (item, true, false), "unable to add item"); + expect (map.addItem (std::move(item), true, false), "unable to add item"); expect (map.getHash().as_uint256() == hashes[i], "bad buildup map hash"); } for (int i = keys.size() - 1; i >= 0; --i) diff --git a/src/ripple/shamap/tests/SHAMapSync.test.cpp b/src/ripple/shamap/tests/SHAMapSync.test.cpp index 3111dbf27..a71e09c61 100644 --- a/src/ripple/shamap/tests/SHAMapSync.test.cpp +++ b/src/ripple/shamap/tests/SHAMapSync.test.cpp @@ -59,7 +59,7 @@ public: std::shared_ptr item = makeRandomAS (); items.push_back (item->key()); - if (!map.addItem (*item, false, false)) + if (!map.addItem (std::move(*item), false, false)) { log << "Unable to add item to map"; @@ -99,7 +99,7 @@ public: int items = 10000; for (int i = 0; i < items; ++i) - source.addItem (*makeRandomAS (), false, false); + source.addItem (std::move(*makeRandomAS ()), false, false); unexpected (!confuseMap (source, 500), "ConfuseMap");