diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 6230d3217e..c01e15b282 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -1719,7 +1719,7 @@ uint256 Ledger::getLedgerHash (std::uint32_t ledgerIndex) STVector256 vec = hashIndex->getFieldV256 (sfHashes); if (vec.size () >= diff) - return vec.at (vec.size () - diff); + return vec[vec.size () - diff]; WriteLog (lsWARNING, Ledger) << "Ledger " << mLedgerSeq @@ -1754,7 +1754,7 @@ uint256 Ledger::getLedgerHash (std::uint32_t ledgerIndex) STVector256 vec = hashIndex->getFieldV256 (sfHashes); if (vec.size () > sDiff) - return vec.at (vec.size () - sDiff - 1); + return vec[vec.size () - sDiff - 1]; } WriteLog (lsWARNING, Ledger) << "Can't get seq " << ledgerIndex @@ -1775,7 +1775,7 @@ Ledger::LedgerHashes Ledger::getLedgerHashes () const auto seq = hashIndex->getFieldU32 (sfLastLedgerSequence) - size; for (int i = 0; i < size; ++i) - ret.push_back (std::make_pair (++seq, vec.at (i))); + ret.push_back (std::make_pair (++seq, vec[i])); } return ret; diff --git a/src/ripple/app/misc/AmendmentTableImpl.cpp b/src/ripple/app/misc/AmendmentTableImpl.cpp index 14d6831e23..fef0a684af 100644 --- a/src/ripple/app/misc/AmendmentTableImpl.cpp +++ b/src/ripple/app/misc/AmendmentTableImpl.cpp @@ -431,9 +431,7 @@ AmendmentTableImpl::doValidation (Ledger::ref lastClosedLedger, STVector256 vAmendments (sfAmendments); for (auto const& uAmendment : lAmendments) - { - vAmendments.addValue (uAmendment); - } + vAmendments.push_back (uAmendment); vAmendments.sort (); baseValidation.setFieldV256 (sfAmendments, vAmendments); } diff --git a/src/ripple/app/misc/NetworkOPs.cpp b/src/ripple/app/misc/NetworkOPs.cpp index d74674bdd3..244943a617 100644 --- a/src/ripple/app/misc/NetworkOPs.cpp +++ b/src/ripple/app/misc/NetworkOPs.cpp @@ -1230,10 +1230,7 @@ Json::Value NetworkOPsImp::getOwnerInfo ( do { - STVector256 svIndexes = sleNode->getFieldV256 (sfIndexes); - const std::vector& vuiIndexes = svIndexes.peekValue (); - - BOOST_FOREACH (uint256 const& uDirEntry, vuiIndexes) + for (auto const& uDirEntry : sleNode->getFieldV256 (sfIndexes)) { auto sleCur = lpLedger->getSLEi (uDirEntry); @@ -1265,7 +1262,7 @@ Json::Value NetworkOPsImp::getOwnerInfo ( } } - uNodeDir = sleNode->getFieldU64 (sfIndexNext); + uNodeDir = sleNode->getFieldU64 (sfIndexNext); if (uNodeDir) { diff --git a/src/ripple/app/paths/PathRequest.cpp b/src/ripple/app/paths/PathRequest.cpp index 8e16867238..a8c8c8db0b 100644 --- a/src/ripple/app/paths/PathRequest.cpp +++ b/src/ripple/app/paths/PathRequest.cpp @@ -464,7 +464,7 @@ Json::Value PathRequest::doUpdate (RippleLineCache::ref cache, bool fast) { m_journal.debug << iIdentifier << " Trying with an extra path element"; - spsPaths.addPath(extraPath); + spsPaths.push_back (extraPath); rc = path::RippleCalc::rippleCalculate (lesSandbox, saMaxAmount, saDstAmount, diff --git a/src/ripple/app/paths/PathState.cpp b/src/ripple/app/paths/PathState.cpp index 6a7c04aa4f..38496052a9 100644 --- a/src/ripple/app/paths/PathState.cpp +++ b/src/ripple/app/paths/PathState.cpp @@ -470,7 +470,7 @@ TER PathState::expandPath ( // Figure out next node properties for implied node. const auto uNxtCurrencyID = spSourcePath.size () - ? Currency(spSourcePath.getElement (0).getCurrency ()) + ? Currency(spSourcePath.front ().getCurrency ()) // Use next node. : currencyOutID; // Use send. @@ -478,7 +478,7 @@ TER PathState::expandPath ( // TODO(tom): complexify this next logic further in case someone // understands it. const auto nextAccountID = spSourcePath.size () - ? Account(spSourcePath.getElement (0).getAccountID ()) + ? Account(spSourcePath. front ().getAccountID ()) : !isXRP(currencyOutID) ? (issuerOutID == uReceiverID) ? Account(uReceiverID) diff --git a/src/ripple/app/paths/Pathfinder.cpp b/src/ripple/app/paths/Pathfinder.cpp index 348ec4cf80..3717bdfd51 100644 --- a/src/ripple/app/paths/Pathfinder.cpp +++ b/src/ripple/app/paths/Pathfinder.cpp @@ -231,7 +231,7 @@ bool Pathfinder::findPaths ( for (auto const& path : pathsOut) { // make sure no paths were lost bool found = false; - if (!path.isEmpty ()) + if (!path.empty ()) { for (auto const& ePath : mCompletePaths) { @@ -242,7 +242,7 @@ bool Pathfinder::findPaths ( } } if (!found) - mCompletePaths.addPath(path); + mCompletePaths.push_back (path); } } @@ -269,7 +269,7 @@ TER Pathfinder::checkPath ( uint64_t& qualityOut) const // The returned initial quality { STPathSet pathSet; - pathSet.addPath (path); + pathSet.push_back (path); // We only want to look at this path path::RippleCalc::Input rcInput; @@ -388,7 +388,7 @@ STPathSet Pathfinder::filterPaths(int iMaxPaths, STPath& extraPath) ": " << currentPath.getJson (0); vMap.push_back (path_LQ_t ( - uQuality, currentPath.mPath.size (), actualOut, i)); + uQuality, currentPath.size (), actualOut, i)); } } @@ -399,7 +399,6 @@ STPathSet Pathfinder::filterPaths(int iMaxPaths, STPath& extraPath) // Lower is better and should be first. std::sort (vMap.begin (), vMap.end (), bQualityCmp); - for (int i = 0, iPathsLeft = iMaxPaths; (iPathsLeft > 0 || extraPath.empty()) && i < vMap.size (); ++i) { @@ -411,7 +410,7 @@ STPathSet Pathfinder::filterPaths(int iMaxPaths, STPath& extraPath) // last path must fill --iPathsLeft; remaining -= std::get<2> (lqt); - spsDst.addPath (mCompletePaths[std::get<3> (lqt)]); + spsDst.push_back (mCompletePaths[std::get<3> (lqt)]); } else if (iPathsLeft == 0 && std::get<2>(lqt) >= mDstAmount && extraPath.empty()) @@ -588,7 +587,7 @@ void Pathfinder::addLink( STPathSet& Pathfinder::getPaths(PathType_t const& type, bool addComplete) { - std::map< PathType_t, STPathSet >::iterator it = mPaths.find(type); + auto it = mPaths.find(type); // We already have these paths if (it != mPaths.end()) @@ -614,37 +613,33 @@ STPathSet& Pathfinder::getPaths(PathType_t const& type, bool addComplete) switch (toAdd) { - - case nt_SOURCE: - - { // source is an empty path - assert(pathsOut.isEmpty()); - pathsOut.addPath(STPath()); - } + case nt_SOURCE: + // source is an empty path + assert(pathsOut.empty()); + pathsOut.push_back (STPath()); break; - case nt_ACCOUNTS: - addLink(pathsIn, pathsOut, afADD_ACCOUNTS); - break; + case nt_ACCOUNTS: + addLink(pathsIn, pathsOut, afADD_ACCOUNTS); + break; - case nt_BOOKS: - addLink(pathsIn, pathsOut, afADD_BOOKS); - break; + case nt_BOOKS: + addLink(pathsIn, pathsOut, afADD_BOOKS); + break; - case nt_XRP_BOOK: - addLink(pathsIn, pathsOut, afADD_BOOKS | afOB_XRP); - break; + case nt_XRP_BOOK: + addLink(pathsIn, pathsOut, afADD_BOOKS | afOB_XRP); + break; - case nt_DEST_BOOK: - addLink(pathsIn, pathsOut, afADD_BOOKS | afOB_LAST); - break; - - case nt_DESTINATION: - // FIXME: What if a different issuer was specified on the - // destination amount? - addLink(pathsIn, pathsOut, afADD_ACCOUNTS | afAC_LAST); - break; + case nt_DEST_BOOK: + addLink(pathsIn, pathsOut, afADD_BOOKS | afOB_LAST); + break; + case nt_DESTINATION: + // FIXME: What if a different issuer was specified on the + // destination amount? + addLink(pathsIn, pathsOut, afADD_ACCOUNTS | afAC_LAST); + break; } CondLog (mCompletePaths.size() != cp, lsDEBUG, Pathfinder) @@ -680,12 +675,12 @@ bool Pathfinder::isNoRippleOut (STPath const& currentPath) return false; // What account are we leaving? - auto const& fromAccount = - (currentPath.size() == 1) ? mSrcAccountID : (currentPath.end() - 2)-> - mAccountID; + auto const& fromAccount = (currentPath.size() == 1) + ? mSrcAccountID + : (currentPath.end() - 2)->getAccountID (); return isNoRipple ( - endElement.mAccountID, fromAccount, endElement.mCurrencyID); + endElement.getAccountID (), fromAccount, endElement.getCurrency ()); } void Pathfinder::addLink( @@ -693,26 +688,37 @@ void Pathfinder::addLink( STPathSet& incompletePaths, // The set of partial paths we add to int addFlags) { - auto const& pathEnd = currentPath.isEmpty() ? - mSource : currentPath.mPath.back (); - auto const& uEndCurrency = pathEnd.mCurrencyID; - auto const& uEndIssuer = pathEnd.mIssuerID; - auto const& uEndAccount = pathEnd.mAccountID; + auto const& pathEnd = currentPath.empty() + ? mSource + : currentPath.back (); + auto const& uEndCurrency = pathEnd.getCurrency (); + auto const& uEndIssuer = pathEnd.getIssuerID (); + auto const& uEndAccount = pathEnd.getAccountID (); bool const bOnXRP = uEndCurrency.isZero(); WriteLog (lsTRACE, Pathfinder) << "addLink< flags=" << addFlags << " onXRP=" << bOnXRP; WriteLog (lsTRACE, Pathfinder) << currentPath.getJson(0); + auto add_unique_path = [](STPathSet& path_set, STPath const& path) + { + for (auto const& p : path_set) + { + if (p == path) + return; + } + path_set.push_back (path); + }; + if (addFlags & afADD_ACCOUNTS) { // add accounts if (bOnXRP) { - if (mDstAmount.isNative() && !currentPath.isEmpty()) + if (mDstAmount.isNative() && !currentPath.empty()) { // non-default path to XRP destination WriteLog (lsTRACE, Pathfinder) << "complete path found ax: " << currentPath.getJson(0); - mCompletePaths.addUniquePath(currentPath); + add_unique_path (mCompletePaths, currentPath); } } else @@ -773,12 +779,12 @@ void Pathfinder::addLink( if (uEndCurrency == mDstAmount.getCurrency()) { // this is a complete path - if (!currentPath.isEmpty()) + if (!currentPath.empty()) { WriteLog (lsTRACE, Pathfinder) << "complete path found ae: " << currentPath.getJson(0); - mCompletePaths.addUniquePath(currentPath); + add_unique_path (mCompletePaths, currentPath); } } else if (!bDestOnly) @@ -873,11 +879,8 @@ void Pathfinder::addLink( { // to XRP // add the order book itself - newPath.addElement(STPathElement( - STPathElement::typeCurrency, - xrpAccount(), - xrpCurrency(), - xrpAccount())); + newPath.emplace_back (STPathElement::typeCurrency, + xrpAccount(), xrpCurrency(), xrpAccount()); if (mDstAmount.getCurrency().isZero()) { @@ -886,10 +889,10 @@ void Pathfinder::addLink( WriteLog (lsTRACE, Pathfinder) << "complete path found bx: " << currentPath.getJson(0); - mCompletePaths.addUniquePath(newPath); + add_unique_path (mCompletePaths, newPath); } else - incompletePaths.addPath(newPath); + incompletePaths.push_back (newPath); } else if (!currentPath.hasSeen( book->getIssuerOut(), @@ -897,12 +900,10 @@ void Pathfinder::addLink( book->getIssuerOut())) { // Don't want the book if we've already seen the issuer // add the order book itself - newPath.addElement( - STPathElement(STPathElement::typeCurrency | - STPathElement::typeIssuer, - xrpAccount(), - book->getCurrencyOut(), book-> - getIssuerOut())); + newPath.emplace_back( + STPathElement::typeCurrency | STPathElement::typeIssuer, + xrpAccount(), book->getCurrencyOut(), + book->getIssuerOut()); if (book->getIssuerOut() == mDstAccountID && book->getCurrencyOut() == mDstAmount.getCurrency()) @@ -910,7 +911,7 @@ void Pathfinder::addLink( WriteLog (lsTRACE, Pathfinder) << "complete path found ba: " << currentPath.getJson(0); - mCompletePaths.addUniquePath(newPath); + add_unique_path (mCompletePaths, newPath); } else { // add issuer's account, path still incomplete diff --git a/src/ripple/app/paths/RippleCalc.cpp b/src/ripple/app/paths/RippleCalc.cpp index ba39d51292..a270a7303f 100644 --- a/src/ripple/app/paths/RippleCalc.cpp +++ b/src/ripple/app/paths/RippleCalc.cpp @@ -159,7 +159,7 @@ TER RippleCalc::rippleCalculate () if (!addPathState (STPath(), resultCode)) return resultCode; } - else if (spsPaths_.isEmpty ()) + else if (spsPaths_.empty ()) { WriteLog (lsDEBUG, RippleCalc) << "rippleCalc: Invalid transaction:" @@ -210,7 +210,7 @@ TER RippleCalc::rippleCalculate () bool multiQuality = false; // Find the best path. - for (auto pathState: pathStateList_) + for (auto pathState : pathStateList_) { if (pathState->quality()) // Only do active paths. diff --git a/src/ripple/app/transactors/Change.cpp b/src/ripple/app/transactors/Change.cpp index f469cf8bcc..8b2f199a0c 100644 --- a/src/ripple/app/transactors/Change.cpp +++ b/src/ripple/app/transactors/Change.cpp @@ -87,7 +87,7 @@ public: TER preCheck () override { - mTxnAccountID = mTxn.getSourceAccount ().getAccountID (); + mTxnAccountID = mTxn.getSourceAccount ().getAccountID (); if (mTxnAccountID.isNonZero ()) { @@ -121,10 +121,13 @@ private: STVector256 amendments (amendmentObject->getFieldV256 (sfAmendments)); - if (amendments.hasValue (amendment)) + if (std::find (amendments.begin(), amendments.end(), + amendment) != amendments.end ()) + { return tefALREADY; + } - amendments.addValue (amendment); + amendments.push_back (amendment); amendmentObject->setFieldV256 (sfAmendments, amendments); mEngine->entryModify (amendmentObject); @@ -138,7 +141,6 @@ private: TER applyFee () { - SLE::pointer feeObject = mEngine->entryCache ( ltFEE_SETTINGS, Ledger::getLedgerFeeIndex ()); diff --git a/src/ripple/data/protocol/STObject.cpp b/src/ripple/data/protocol/STObject.cpp index e2e6597d2e..757491167f 100644 --- a/src/ripple/data/protocol/STObject.cpp +++ b/src/ripple/data/protocol/STObject.cpp @@ -744,13 +744,13 @@ const STArray& STObject::getFieldArray (SField::ref field) const STPathSet const& STObject::getFieldPathSet (SField::ref field) const { - static STPathSet const empty; + static STPathSet const empty{}; return getFieldByConstRef (field, empty); } const STVector256& STObject::getFieldV256 (SField::ref field) const { - static STVector256 const empty; + static STVector256 const empty{}; return getFieldByConstRef (field, empty); } @@ -897,16 +897,6 @@ bool STObject::operator== (const STObject& obj) const return true; } -Json::Value STVector256::getJson (int options) const -{ - Json::Value ret (Json::arrayValue); - - for (auto const& vEntry : mValue) - ret.append (to_string (vEntry)); - - return ret; -} - //------------------------------------------------------------------------------ class SerializedObject_test : public beast::unit_test::suite diff --git a/src/ripple/data/protocol/STParsedJSON.cpp b/src/ripple/data/protocol/STParsedJSON.cpp index e4b6a7541f..9de6835d9a 100644 --- a/src/ripple/data/protocol/STParsedJSON.cpp +++ b/src/ripple/data/protocol/STParsedJSON.cpp @@ -444,7 +444,7 @@ bool STParsedJSON::parse (std::string const& json_name, { uint256 s; s.SetHex (value[i].asString ()); - tail->addValue (s); + tail->push_back (s); } } catch (...) @@ -581,10 +581,10 @@ bool STParsedJSON::parse (std::string const& json_name, } } - p.addElement (STPathElement (uAccount, uCurrency, uIssuer, hasCurrency)); + p.emplace_back (uAccount, uCurrency, uIssuer, hasCurrency); } - tail->addPath (p); + tail->push_back (p); } } catch (...) diff --git a/src/ripple/data/protocol/SerializedTypes.cpp b/src/ripple/data/protocol/SerializedTypes.cpp index bea048222e..2f4087e761 100644 --- a/src/ripple/data/protocol/SerializedTypes.cpp +++ b/src/ripple/data/protocol/SerializedTypes.cpp @@ -149,15 +149,14 @@ bool STVector256::isEquivalent (const SerializedType& t) const return v && (mValue == v->mValue); } -bool STVector256::hasValue (uint256 const& v) const +Json::Value STVector256::getJson (int) const { - BOOST_FOREACH (uint256 const& hash, mValue) - { - if (hash == v) - return true; - } + Json::Value ret (Json::arrayValue); - return false; + for (auto const& vEntry : mValue) + ret.append (to_string (vEntry)); + + return ret; } // @@ -329,59 +328,20 @@ Json::Value STPathSet::getJson (int options) const return ret; } -#if 0 -std::string STPath::getText () const -{ - std::string ret ("["); - bool first = true; - - BOOST_FOREACH (const STPathElement & it, mPath) - { - if (!first) ret += ", "; - - switch (it.getNodeType ()) - { - case STPathElement::typeAccount: - { - ret += to_string (it.getNode ()); - break; - } - - case STPathElement::typeOffer: - { - ret += "Offer("; - ret += it.getNode ().GetHex (); - ret += ")"; - break; - } - - default: - throw std::runtime_error ("Unknown path element"); - } - - first = false; - } - - return ret + "]"; -} -#endif - void STPathSet::add (Serializer& s) const { assert (fName->isBinary ()); assert (fName->fieldType == STI_PATHSET); - bool bFirst = true; + bool first = true; - BOOST_FOREACH (const STPath & spPath, value) + for (auto const& spPath : value) { - if (!bFirst) - { + if (!first) s.add8 (STPathElement::typeBoundary); - } - BOOST_FOREACH (const STPathElement & speElement, spPath) + for (auto const& speElement : spPath) { - int iType = speElement.getNodeType (); + int iType = speElement.getNodeType (); s.add8 (iType); @@ -395,8 +355,9 @@ void STPathSet::add (Serializer& s) const s.add160 (speElement.getIssuerID ()); } - bFirst = false; + first = false; } + s.add8 (STPathElement::typeNone); } diff --git a/src/ripple/data/protocol/SerializedTypes.h b/src/ripple/data/protocol/SerializedTypes.h index abe1d443b7..9609bb3c32 100644 --- a/src/ripple/data/protocol/SerializedTypes.h +++ b/src/ripple/data/protocol/SerializedTypes.h @@ -174,12 +174,6 @@ private: class STPathElement { -private: - // VFALCO Remove these friend declarations - friend class STPathSet; - friend class STPath; - friend class Pathfinder; - public: enum Type { @@ -283,65 +277,48 @@ private: class STPath { public: - STPath () - { - ; - } - STPath (const std::vector& p) : mPath (p) - { - ; - } + STPath () = default; - int size () const + STPath (std::vector const& p) + : mPath (p) + { } + + std::vector::size_type + size () const { return mPath.size (); } - void reserve (size_t n) - { - mPath.reserve(n); - } - bool isEmpty () const - { - return mPath.empty (); - } + bool empty() const { return mPath.empty (); } - const STPathElement& getElement (int offset) const - { - return mPath[offset]; - } - const STPathElement& getElement (int offset) - { - return mPath[offset]; - } - void addElement (const STPathElement& e) + void + push_back (STPathElement const& e) { mPath.push_back (e); } - void clear () + + template + void + emplace_back (Args&&... args) { - mPath.clear (); + mPath.emplace_back (std::forward (args)...); } + bool hasSeen (Account const& account, Currency const& currency, Account const& issuer) const; Json::Value getJson (int) const; - std::vector::iterator begin () + std::vector::const_iterator + begin () const { return mPath.begin (); } - std::vector::iterator end () - { - return mPath.end (); - } - std::vector::const_iterator begin () const - { - return mPath.begin (); - } - std::vector::const_iterator end () const + + std::vector::const_iterator + end () const { return mPath.end (); } @@ -351,12 +328,19 @@ public: return mPath == t.mPath; } - void setCanonical (STPath const& spExpanded); + std::vector::const_reference + back () const + { + return mPath.back (); + } + + std::vector::const_reference + front () const + { + return mPath.front (); + } private: - friend class STPathSet; - friend class Pathfinder; - std::vector mPath; }; @@ -366,32 +350,19 @@ private: class STPathSet : public SerializedType { public: - STPathSet () - { - ; - } + STPathSet () = default; - explicit STPathSet (SField::ref n) : SerializedType (n) - { - ; - } + STPathSet (SField::ref n) + : SerializedType (n) + { } - explicit STPathSet (const std::vector& v) : value (v) - { - ; - } - - STPathSet (SField::ref n, const std::vector& v) : SerializedType (n), value (v) - { - ; - } - - static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) + static + std::unique_ptr + deserialize (SerializerIterator& sit, SField::ref name) { return std::unique_ptr (construct (sit, name)); } - // std::string getText() const; void add (Serializer& s) const; virtual Json::Value getJson (int) const; @@ -399,41 +370,19 @@ public: { return STI_PATHSET; } - int size () const + std::vector::size_type + size () const { return value.size (); } - void reserve (size_t n) - { - value.reserve(n); - } - STPath const& getPath (int off) const - { - return value[off]; - } - STPath& peekPath (int off) - { - return value[off]; - } - bool isEmpty () const + + bool empty () const { return value.empty (); } - void clear () + + void push_back (STPath const& e) { - value.clear (); - } - void addPath (STPath const& e) - { - value.push_back (e); - } - void addUniquePath (STPath const& e) - { - for (auto const& p: value) - { - if (p == e) - return; - } value.push_back (e); } @@ -444,11 +393,11 @@ public: std::vector::reverse_iterator it = value.rbegin (); STPath& newPath = *it; - newPath.mPath.push_back (tail); + newPath.push_back (tail); while (++it != value.rend ()) { - if (it->mPath == newPath.mPath) + if (*it == newPath) { value.pop_back (); return false; @@ -463,27 +412,17 @@ public: return value.empty (); } - STPath& operator[](size_t n) - { - return value[n]; - } - STPath const& operator[](size_t n) const + std::vector::const_reference + operator[] (std::vector::size_type n) const { return value[n]; } - std::vector::iterator begin () - { - return value.begin (); - } - std::vector::iterator end () - { - return value.end (); - } std::vector::const_iterator begin () const { return value.begin (); } + std::vector::const_iterator end () const { return value.end (); @@ -492,11 +431,18 @@ public: private: std::vector value; + STPathSet (SField::ref n, const std::vector& v) + : SerializedType (n), value (v) + { } + STPathSet* duplicate () const { return new STPathSet (*this); } - static STPathSet* construct (SerializerIterator&, SField::ref); + + static + STPathSet* + construct (SerializerIterator&, SField::ref); }; //------------------------------------------------------------------------------ @@ -504,22 +450,13 @@ private: class STVector256 : public SerializedType { public: - STVector256 () - { - ; - } - STVector256 (SField::ref n) : SerializedType (n) - { - ; - } - STVector256 (SField::ref n, const std::vector& v) : SerializedType (n), mValue (v) - { - ; - } - STVector256 (const std::vector& vector) : mValue (vector) - { - ; - } + STVector256 () = default; + explicit STVector256 (SField::ref n) + : SerializedType (n) + { } + explicit STVector256 (std::vector const& vector) + : mValue (vector) + { } SerializedTypeID getSType () const { @@ -527,62 +464,57 @@ public: } void add (Serializer& s) const; - static std::unique_ptr deserialize (SerializerIterator& sit, SField::ref name) + static + std::unique_ptr + deserialize (SerializerIterator& sit, SField::ref name) { return std::unique_ptr (construct (sit, name)); } - const std::vector& peekValue () const + const std::vector& + peekValue () const { return mValue; } - std::vector& peekValue () + + std::vector& + peekValue () { return mValue; } + virtual bool isEquivalent (const SerializedType& t) const; virtual bool isDefault () const { return mValue.empty (); } - std::vector getValue () const - { - return mValue; - } - int size () const + std::vector::size_type + size () const { return mValue.size (); } - bool isEmpty () const + bool empty () const { return mValue.empty (); } - uint256 const& at (int i) const + std::vector::const_reference + operator[] (std::vector::size_type n) const { - assert ((i >= 0) && (i < size ())); - return mValue.at (i); - } - uint256& at (int i) - { - assert ((i >= 0) && (i < size ())); - return mValue.at (i); + return mValue[n]; } void setValue (const STVector256& v) { mValue = v.mValue; } - void setValue (const std::vector& v) - { - mValue = v; - } - void addValue (uint256 const& v) + + void push_back (uint256 const& v) { mValue.push_back (v); } - bool hasValue (uint256 const& v) const; + void sort () { std::sort (mValue.begin (), mValue.end ()); @@ -590,11 +522,13 @@ public: Json::Value getJson (int) const; - std::vector::const_iterator begin() const + std::vector::const_iterator + begin() const { return mValue.begin (); } - std::vector::const_iterator end() const + std::vector::const_iterator + end() const { return mValue.end (); } diff --git a/src/ripple/rpc/handlers/RipplePathFind.cpp b/src/ripple/rpc/handlers/RipplePathFind.cpp index 5e48f7f66d..f917fc69cb 100644 --- a/src/ripple/rpc/handlers/RipplePathFind.cpp +++ b/src/ripple/rpc/handlers/RipplePathFind.cpp @@ -247,7 +247,7 @@ Json::Value doRipplePathFind (RPC::Context& context) WriteLog (lsDEBUG, PathRequest) << "Trying with an extra path element"; - spsComputed.addPath(extraPath); + spsComputed.push_back (extraPath); lesSandbox.clear (); rc = path::RippleCalc::rippleCalculate ( lesSandbox, diff --git a/src/ripple/rpc/impl/TransactionSign.cpp b/src/ripple/rpc/impl/TransactionSign.cpp index 92483f319f..b571bffecc 100644 --- a/src/ripple/rpc/impl/TransactionSign.cpp +++ b/src/ripple/rpc/impl/TransactionSign.cpp @@ -177,7 +177,7 @@ static Json::Value signPayment( << "transactionSign: build_path: " << spsPaths.getJson (0); - if (!spsPaths.isEmpty ()) + if (!spsPaths.empty ()) tx_json["Paths"] = spsPaths.getJson (0); } }