mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-21 03:26:01 +00:00
Second round of removing extraneous copy constructor and destructor calls.
This commit is contained in:
@@ -365,7 +365,7 @@ Json::Value ConnectionPool::getPeersJson()
|
|||||||
Json::Value ret(Json::arrayValue);
|
Json::Value ret(Json::arrayValue);
|
||||||
std::vector<Peer::pointer> vppPeers = getPeerVector();
|
std::vector<Peer::pointer> vppPeers = getPeerVector();
|
||||||
|
|
||||||
BOOST_FOREACH(Peer::pointer peer, vppPeers)
|
BOOST_FOREACH(Peer::ref peer, vppPeers)
|
||||||
{
|
{
|
||||||
ret.append(peer->getJson());
|
ret.append(peer->getJson());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class LedgerEntryFormat
|
|||||||
public:
|
public:
|
||||||
std::string t_name;
|
std::string t_name;
|
||||||
LedgerEntryType t_type;
|
LedgerEntryType t_type;
|
||||||
std::vector<SOElement::ptr> elements;
|
std::vector<SOElement::ref> elements;
|
||||||
|
|
||||||
static std::map<int, LedgerEntryFormat*> byType;
|
static std::map<int, LedgerEntryFormat*> byType;
|
||||||
static std::map<std::string, LedgerEntryFormat*> byName;
|
static std::map<std::string, LedgerEntryFormat*> byName;
|
||||||
|
|||||||
@@ -571,7 +571,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
|||||||
boost::unordered_map<uint256, currentValidationCount> current =
|
boost::unordered_map<uint256, currentValidationCount> current =
|
||||||
theApp->getValidations().getCurrentValidations(closedLedger);
|
theApp->getValidations().getCurrentValidations(closedLedger);
|
||||||
typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair;
|
typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair;
|
||||||
BOOST_FOREACH(u256_cvc_pair& it, current)
|
BOOST_FOREACH(const u256_cvc_pair& it, current)
|
||||||
{
|
{
|
||||||
ValidationCount& vc = ledgers[it.first];
|
ValidationCount& vc = ledgers[it.first];
|
||||||
vc.trustedValidations += it.second.first;
|
vc.trustedValidations += it.second.first;
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class OrderBook
|
|||||||
OrderBook(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
|
OrderBook(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<OrderBook> pointer;
|
typedef boost::shared_ptr<OrderBook> pointer;
|
||||||
|
typedef const boost::shared_ptr<OrderBook>& ref;
|
||||||
|
|
||||||
// returns NULL if ledgerEntry doesn't point to an order
|
// returns NULL if ledgerEntry doesn't point to an order
|
||||||
// if ledgerEntry is an Order it creates the OrderBook this order would live in
|
// if ledgerEntry is an Order it creates the OrderBook this order would live in
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ void OrderBookDB::getBooks(const uint160& issuerID, const uint160& currencyID, s
|
|||||||
{
|
{
|
||||||
if( mIssuerMap.find(issuerID) == mIssuerMap.end() )
|
if( mIssuerMap.find(issuerID) == mIssuerMap.end() )
|
||||||
{
|
{
|
||||||
BOOST_FOREACH(OrderBook::pointer book, mIssuerMap[issuerID])
|
BOOST_FOREACH(OrderBook::ref book, mIssuerMap[issuerID])
|
||||||
{
|
{
|
||||||
if(book->getCurrencyIn()==currencyID)
|
if(book->getCurrencyIn()==currencyID)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
else if (!speEnd.mCurrencyID)
|
else if (!speEnd.mCurrencyID)
|
||||||
{
|
{
|
||||||
// Last element is for XRP continue with qualifying books.
|
// Last element is for XRP continue with qualifying books.
|
||||||
BOOST_FOREACH(OrderBook::pointer book, mOrderBook.getXRPInBooks())
|
BOOST_FOREACH(OrderBook::ref book, mOrderBook.getXRPInBooks())
|
||||||
{
|
{
|
||||||
// XXX Don't allow looping through same order books.
|
// XXX Don't allow looping through same order books.
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
// Create new paths for each outbound account not already in the path.
|
// Create new paths for each outbound account not already in the path.
|
||||||
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
|
AccountItems rippleLines(speEnd.mAccountID, mLedger, AccountItem::pointer(new RippleState()));
|
||||||
|
|
||||||
BOOST_FOREACH(AccountItem::pointer item, rippleLines.getItems())
|
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
|
||||||
{
|
{
|
||||||
RippleState* line=(RippleState*)item.get();
|
RippleState* line=(RippleState*)item.get();
|
||||||
|
|
||||||
@@ -342,7 +342,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
|
|
||||||
mOrderBook.getBooks(spPath.mCurrentAccount, spPath.mCurrencyID, books);
|
mOrderBook.getBooks(spPath.mCurrentAccount, spPath.mCurrencyID, books);
|
||||||
|
|
||||||
BOOST_FOREACH(OrderBook::pointer book,books)
|
BOOST_FOREACH(OrderBook::ref book,books)
|
||||||
{
|
{
|
||||||
STPath new_path(spPath);
|
STPath new_path(spPath);
|
||||||
STPathElement new_ele(uint160(), book->getCurrencyOut(), book->getIssuerOut());
|
STPathElement new_ele(uint160(), book->getCurrencyOut(), book->getIssuerOut());
|
||||||
@@ -457,7 +457,7 @@ bool Pathfinder::checkComplete(STPathSet& retPathSet)
|
|||||||
if (mCompletePaths.size())
|
if (mCompletePaths.size())
|
||||||
{ // TODO: look through these and pick the most promising
|
{ // TODO: look through these and pick the most promising
|
||||||
int count=0;
|
int count=0;
|
||||||
BOOST_FOREACH(PathOption::pointer pathOption,mCompletePaths)
|
BOOST_FOREACH(PathOption::ref pathOption,mCompletePaths)
|
||||||
{
|
{
|
||||||
retPathSet.addPath(pathOption->mPath);
|
retPathSet.addPath(pathOption->mPath);
|
||||||
count++;
|
count++;
|
||||||
@@ -480,7 +480,7 @@ void Pathfinder::addOptions(PathOption::pointer tail)
|
|||||||
{
|
{
|
||||||
if (!tail->mCurrencyID)
|
if (!tail->mCurrencyID)
|
||||||
{ // source XRP
|
{ // source XRP
|
||||||
BOOST_FOREACH(OrderBook::pointer book, mOrderBook.getXRPInBooks())
|
BOOST_FOREACH(OrderBook::ref book, mOrderBook.getXRPInBooks())
|
||||||
{
|
{
|
||||||
PathOption::pointer pathOption(new PathOption(tail));
|
PathOption::pointer pathOption(new PathOption(tail));
|
||||||
|
|
||||||
@@ -495,7 +495,7 @@ void Pathfinder::addOptions(PathOption::pointer tail)
|
|||||||
else
|
else
|
||||||
{ // ripple
|
{ // ripple
|
||||||
RippleLines rippleLines(tail->mCurrentAccount);
|
RippleLines rippleLines(tail->mCurrentAccount);
|
||||||
BOOST_FOREACH(RippleState::pointer line,rippleLines.getLines())
|
BOOST_FOREACH(RippleState::ref line,rippleLines.getLines())
|
||||||
{
|
{
|
||||||
// TODO: make sure we can move in the correct direction
|
// TODO: make sure we can move in the correct direction
|
||||||
STAmount balance=line->getBalance();
|
STAmount balance=line->getBalance();
|
||||||
@@ -516,7 +516,7 @@ void Pathfinder::addOptions(PathOption::pointer tail)
|
|||||||
std::vector<OrderBook::pointer> books;
|
std::vector<OrderBook::pointer> books;
|
||||||
mOrderBook.getBooks(tail->mCurrentAccount, tail->mCurrencyID, books);
|
mOrderBook.getBooks(tail->mCurrentAccount, tail->mCurrencyID, books);
|
||||||
|
|
||||||
BOOST_FOREACH(OrderBook::pointer book,books)
|
BOOST_FOREACH(OrderBook::ref book,books)
|
||||||
{
|
{
|
||||||
PathOption::pointer pathOption(new PathOption(tail));
|
PathOption::pointer pathOption(new PathOption(tail));
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class PathOption
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::shared_ptr<PathOption> pointer;
|
typedef boost::shared_ptr<PathOption> pointer;
|
||||||
|
typedef const boost::shared_ptr<PathOption>& ref;
|
||||||
|
|
||||||
STPath mPath;
|
STPath mPath;
|
||||||
bool mCorrectCurrency; // for the sorting
|
bool mCorrectCurrency; // for the sorting
|
||||||
|
|||||||
@@ -564,7 +564,7 @@ Json::Value RPCHandler::doAccountLines(Json::Value jvRequest)
|
|||||||
|
|
||||||
AccountItems rippleLines(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new RippleState()));
|
AccountItems rippleLines(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new RippleState()));
|
||||||
|
|
||||||
BOOST_FOREACH(AccountItem::pointer item, rippleLines.getItems())
|
BOOST_FOREACH(AccountItem::ref item, rippleLines.getItems())
|
||||||
{
|
{
|
||||||
RippleState* line=(RippleState*)item.get();
|
RippleState* line=(RippleState*)item.get();
|
||||||
|
|
||||||
@@ -633,7 +633,7 @@ Json::Value RPCHandler::doAccountOffers(Json::Value jvRequest)
|
|||||||
Json::Value jsonLines(Json::arrayValue);
|
Json::Value jsonLines(Json::arrayValue);
|
||||||
|
|
||||||
AccountItems offers(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new Offer()));
|
AccountItems offers(raAccount.getAccountID(), lpLedger, AccountItem::pointer(new Offer()));
|
||||||
BOOST_FOREACH(AccountItem::pointer item, offers.getItems())
|
BOOST_FOREACH(AccountItem::ref item, offers.getItems())
|
||||||
{
|
{
|
||||||
Offer* offer=(Offer*)item.get();
|
Offer* offer=(Offer*)item.get();
|
||||||
|
|
||||||
|
|||||||
@@ -130,12 +130,12 @@ std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void STObject::set(const std::vector<SOElement::ptr>& type)
|
void STObject::set(const std::vector<SOElement::ref>& type)
|
||||||
{
|
{
|
||||||
mData.clear();
|
mData.clear();
|
||||||
mType.clear();
|
mType.clear();
|
||||||
|
|
||||||
BOOST_FOREACH(const SOElement::ptr& elem, type)
|
BOOST_FOREACH(SOElement::ref elem, type)
|
||||||
{
|
{
|
||||||
mType.push_back(elem);
|
mType.push_back(elem);
|
||||||
if (elem->flags != SOE_REQUIRED)
|
if (elem->flags != SOE_REQUIRED)
|
||||||
@@ -145,13 +145,13 @@ void STObject::set(const std::vector<SOElement::ptr>& type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STObject::setType(const std::vector<SOElement::ptr> &type)
|
bool STObject::setType(const std::vector<SOElement::ref> &type)
|
||||||
{
|
{
|
||||||
boost::ptr_vector<SerializedType> newData;
|
boost::ptr_vector<SerializedType> newData;
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
|
|
||||||
mType.clear();
|
mType.clear();
|
||||||
BOOST_FOREACH(const SOElement::ptr& elem, type)
|
BOOST_FOREACH(SOElement::ref elem, type)
|
||||||
{
|
{
|
||||||
bool match = false;
|
bool match = false;
|
||||||
for (boost::ptr_vector<SerializedType>::iterator it = mData.begin(); it != mData.end(); ++it)
|
for (boost::ptr_vector<SerializedType>::iterator it = mData.begin(); it != mData.end(); ++it)
|
||||||
@@ -200,7 +200,7 @@ bool STObject::setType(const std::vector<SOElement::ptr> &type)
|
|||||||
bool STObject::isValidForType()
|
bool STObject::isValidForType()
|
||||||
{
|
{
|
||||||
boost::ptr_vector<SerializedType>::iterator it = mData.begin();
|
boost::ptr_vector<SerializedType>::iterator it = mData.begin();
|
||||||
BOOST_FOREACH(SOElement::ptr elem, mType)
|
BOOST_FOREACH(SOElement::ref elem, mType)
|
||||||
{
|
{
|
||||||
if (it == mData.end())
|
if (it == mData.end())
|
||||||
return false;
|
return false;
|
||||||
@@ -216,7 +216,7 @@ bool STObject::isFieldAllowed(SField::ref field)
|
|||||||
{
|
{
|
||||||
if (isFree())
|
if (isFree())
|
||||||
return true;
|
return true;
|
||||||
BOOST_FOREACH(SOElement::ptr elem, mType)
|
BOOST_FOREACH(SOElement::ref elem, mType)
|
||||||
{ // are any required elemnents missing
|
{ // are any required elemnents missing
|
||||||
if (elem->e_field == field)
|
if (elem->e_field == field)
|
||||||
return true;
|
return true;
|
||||||
@@ -1242,7 +1242,7 @@ BOOST_AUTO_TEST_CASE( FieldManipulation_test )
|
|||||||
SField sfTestU32(STI_UINT32, 255, "TestU32");
|
SField sfTestU32(STI_UINT32, 255, "TestU32");
|
||||||
SField sfTestObject(STI_OBJECT, 255, "TestObject");
|
SField sfTestObject(STI_OBJECT, 255, "TestObject");
|
||||||
|
|
||||||
std::vector<SOElement::ptr> elements;
|
std::vector<SOElement::ref> elements;
|
||||||
elements.push_back(new SOElement(sfFlags, SOE_REQUIRED));
|
elements.push_back(new SOElement(sfFlags, SOE_REQUIRED));
|
||||||
elements.push_back(new SOElement(sfTestVL, SOE_REQUIRED));
|
elements.push_back(new SOElement(sfTestVL, SOE_REQUIRED));
|
||||||
elements.push_back(new SOElement(sfTestH256, SOE_OPTIONAL));
|
elements.push_back(new SOElement(sfTestH256, SOE_OPTIONAL));
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ DEFINE_INSTANCE(SerializedArray);
|
|||||||
class SOElement
|
class SOElement
|
||||||
{ // An element in the description of a serialized object
|
{ // An element in the description of a serialized object
|
||||||
public:
|
public:
|
||||||
typedef SOElement const * ptr; // used to point to one element
|
typedef SOElement const * ref; // used to point to one element
|
||||||
|
|
||||||
SField::ref e_field;
|
SField::ref e_field;
|
||||||
const SOE_Flags flags;
|
const SOE_Flags flags;
|
||||||
@@ -29,8 +29,8 @@ public:
|
|||||||
class STObject : public SerializedType, private IS_INSTANCE(SerializedObject)
|
class STObject : public SerializedType, private IS_INSTANCE(SerializedObject)
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
boost::ptr_vector<SerializedType> mData;
|
boost::ptr_vector<SerializedType> mData;
|
||||||
std::vector<SOElement::ptr> mType;
|
std::vector<SOElement::ref> mType;
|
||||||
|
|
||||||
STObject* duplicate() const { return new STObject(*this); }
|
STObject* duplicate() const { return new STObject(*this); }
|
||||||
STObject(SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType(name) { mData.swap(data); }
|
STObject(SField::ref name, boost::ptr_vector<SerializedType>& data) : SerializedType(name) { mData.swap(data); }
|
||||||
@@ -40,10 +40,10 @@ public:
|
|||||||
|
|
||||||
STObject(SField::ref name) : SerializedType(name) { ; }
|
STObject(SField::ref name) : SerializedType(name) { ; }
|
||||||
|
|
||||||
STObject(const std::vector<SOElement::ptr>& type, SField::ref name) : SerializedType(name)
|
STObject(const std::vector<SOElement::ref>& type, SField::ref name) : SerializedType(name)
|
||||||
{ set(type); }
|
{ set(type); }
|
||||||
|
|
||||||
STObject(const std::vector<SOElement::ptr>& type, SerializerIterator& sit, SField::ref name) : SerializedType(name)
|
STObject(const std::vector<SOElement::ref>& type, SerializerIterator& sit, SField::ref name) : SerializedType(name)
|
||||||
{ set(sit); setType(type); }
|
{ set(sit); setType(type); }
|
||||||
|
|
||||||
std::auto_ptr<STObject> oClone() const { return std::auto_ptr<STObject>(new STObject(*this)); }
|
std::auto_ptr<STObject> oClone() const { return std::auto_ptr<STObject>(new STObject(*this)); }
|
||||||
@@ -54,12 +54,12 @@ public:
|
|||||||
|
|
||||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name);
|
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name);
|
||||||
|
|
||||||
bool setType(const std::vector<SOElement::ptr>& type);
|
bool setType(const std::vector<SOElement::ref>& type);
|
||||||
bool isValidForType();
|
bool isValidForType();
|
||||||
bool isFieldAllowed(SField::ref);
|
bool isFieldAllowed(SField::ref);
|
||||||
bool isFree() const { return mType.empty(); }
|
bool isFree() const { return mType.empty(); }
|
||||||
|
|
||||||
void set(const std::vector<SOElement::ptr>&);
|
void set(const std::vector<SOElement::ref>&);
|
||||||
bool set(SerializerIterator& u, int depth = 0);
|
bool set(SerializerIterator& u, int depth = 0);
|
||||||
|
|
||||||
virtual SerializedTypeID getSType() const { return STI_OBJECT; }
|
virtual SerializedTypeID getSType() const { return STI_OBJECT; }
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
DECLARE_INSTANCE(SerializedValidation);
|
DECLARE_INSTANCE(SerializedValidation);
|
||||||
|
|
||||||
std::vector<SOElement::ptr> sValidationFormat;
|
std::vector<SOElement::ref> sValidationFormat;
|
||||||
|
|
||||||
static bool SVFInit()
|
static bool SVFInit()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class TransactionFormat
|
|||||||
public:
|
public:
|
||||||
std::string t_name;
|
std::string t_name;
|
||||||
TransactionType t_type;
|
TransactionType t_type;
|
||||||
std::vector<SOElement::ptr> elements;
|
std::vector<SOElement::ref> elements;
|
||||||
|
|
||||||
static std::map<int, TransactionFormat*> byType;
|
static std::map<int, TransactionFormat*> byType;
|
||||||
static std::map<std::string, TransactionFormat*> byName;
|
static std::map<std::string, TransactionFormat*> byName;
|
||||||
|
|||||||
@@ -468,8 +468,8 @@ void UniqueNodeList::scoreCompute()
|
|||||||
// map of pair<IP,Port> :: score
|
// map of pair<IP,Port> :: score
|
||||||
epScore umScore;
|
epScore umScore;
|
||||||
|
|
||||||
std::pair< std::string, int> vc;
|
typedef boost::unordered_map<std::string, int>::value_type vcType;
|
||||||
BOOST_FOREACH(vc, umValidators)
|
BOOST_FOREACH(vcType& vc, umValidators)
|
||||||
{
|
{
|
||||||
std::string strValidator = vc.first;
|
std::string strValidator = vc.first;
|
||||||
|
|
||||||
@@ -506,8 +506,8 @@ void UniqueNodeList::scoreCompute()
|
|||||||
|
|
||||||
vstrValues.reserve(umScore.size());
|
vstrValues.reserve(umScore.size());
|
||||||
|
|
||||||
std::pair< ipPort, score> ipScore;
|
typedef boost::unordered_map<std::pair< std::string, int>, score>::value_type ipScoreType;
|
||||||
BOOST_FOREACH(ipScore, umScore)
|
BOOST_FOREACH(ipScoreType& ipScore, umScore)
|
||||||
{
|
{
|
||||||
ipPort ipEndpoint = ipScore.first;
|
ipPort ipEndpoint = ipScore.first;
|
||||||
std::string strIpPort = str(boost::format("%s %d") % ipEndpoint.first % ipEndpoint.second);
|
std::string strIpPort = str(boost::format("%s %d") % ipEndpoint.first % ipEndpoint.second);
|
||||||
@@ -638,7 +638,7 @@ void UniqueNodeList::processIps(const std::string& strSite, const RippleAddress&
|
|||||||
vstrValues.resize(MIN(pmtVecStrIps->size(), REFERRAL_IPS_MAX));
|
vstrValues.resize(MIN(pmtVecStrIps->size(), REFERRAL_IPS_MAX));
|
||||||
|
|
||||||
int iValues = 0;
|
int iValues = 0;
|
||||||
BOOST_FOREACH(std::string strReferral, *pmtVecStrIps)
|
BOOST_FOREACH(const std::string& strReferral, *pmtVecStrIps)
|
||||||
{
|
{
|
||||||
if (iValues == REFERRAL_VALIDATORS_MAX)
|
if (iValues == REFERRAL_VALIDATORS_MAX)
|
||||||
break;
|
break;
|
||||||
@@ -709,7 +709,7 @@ int UniqueNodeList::processValidators(const std::string& strSite, const std::str
|
|||||||
|
|
||||||
vstrValues.reserve(MIN(pmtVecStrValidators->size(), REFERRAL_VALIDATORS_MAX));
|
vstrValues.reserve(MIN(pmtVecStrValidators->size(), REFERRAL_VALIDATORS_MAX));
|
||||||
|
|
||||||
BOOST_FOREACH(std::string strReferral, *pmtVecStrValidators)
|
BOOST_FOREACH(const std::string& strReferral, *pmtVecStrValidators)
|
||||||
{
|
{
|
||||||
if (iValues == REFERRAL_VALIDATORS_MAX)
|
if (iValues == REFERRAL_VALIDATORS_MAX)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user