mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 06:55:50 +00:00
Round one of fixes to avoid ridiculous numbers of spurious copy constructor and destructor calls.
Most of these fixes involve calls to BOOST_FOREACH to iterate over a map or unordered_map where the iterator type didn't perfectly match the internal type, so a reference into the map couldn't be created and a new value/content pair had to be created for each iteration.
This commit is contained in:
@@ -140,7 +140,7 @@ bool ConnectionPool::peerAvailable(std::string& strIp, int& iPort)
|
||||
|
||||
vstrIpPort.reserve(mIpMap.size());
|
||||
|
||||
BOOST_FOREACH(pipPeer ipPeer, mIpMap)
|
||||
BOOST_FOREACH(const vtPeer& ipPeer, mIpMap)
|
||||
{
|
||||
const std::string& strIp = ipPeer.first.first;
|
||||
int iPort = ipPeer.first.second;
|
||||
@@ -251,7 +251,7 @@ int ConnectionPool::relayMessage(Peer* fromPeer, const PackedMessage::pointer& m
|
||||
int sentTo = 0;
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
BOOST_FOREACH(const vtConMap& pair, mConnectedMap)
|
||||
{
|
||||
Peer::ref peer = pair.second;
|
||||
if (!peer)
|
||||
@@ -270,7 +270,7 @@ void ConnectionPool::relayMessageBut(const std::set<uint64>& fromPeers, const Pa
|
||||
{ // Relay message to all but the specified peers
|
||||
boost::mutex::scoped_lock sl(mPeerLock);
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
BOOST_FOREACH(const vtConMap& pair, mConnectedMap)
|
||||
{
|
||||
Peer::ref peer = pair.second;
|
||||
if (peer->isConnected() && (fromPeers.count(peer->getPeerId()) == 0))
|
||||
@@ -388,7 +388,7 @@ std::vector<Peer::pointer> ConnectionPool::getPeerVector()
|
||||
|
||||
ret.reserve(mConnectedMap.size());
|
||||
|
||||
BOOST_FOREACH(naPeer pair, mConnectedMap)
|
||||
BOOST_FOREACH(const vtConMap& pair, mConnectedMap)
|
||||
{
|
||||
assert(!!pair.second);
|
||||
ret.push_back(pair.second);
|
||||
|
||||
@@ -21,6 +21,7 @@ private:
|
||||
|
||||
typedef std::pair<RippleAddress, Peer::pointer> naPeer;
|
||||
typedef std::pair<ipPort, Peer::pointer> pipPeer;
|
||||
typedef std::map<ipPort, Peer::pointer>::value_type vtPeer;
|
||||
|
||||
// Peers we are connecting with and non-thin peers we are connected to.
|
||||
// Only peers we know the connection ip for are listed.
|
||||
@@ -31,6 +32,7 @@ private:
|
||||
|
||||
// Non-thin peers which we are connected to.
|
||||
// Peers we have the public key for.
|
||||
typedef boost::unordered_map<RippleAddress, Peer::pointer>::value_type vtConMap;
|
||||
boost::unordered_map<RippleAddress, Peer::pointer> mConnectedMap;
|
||||
|
||||
// Connections with have a 64-bit identifier
|
||||
|
||||
@@ -128,7 +128,7 @@ void FeatureTable::reportValidations(const FeatureSet& set)
|
||||
return;
|
||||
int threshold = (set.mTrustedValidations * mMajorityFraction) / 256;
|
||||
|
||||
typedef std::pair<const uint256, int> u256_int_pair;
|
||||
typedef std::map<uint256, int>::value_type u256_int_pair;
|
||||
|
||||
boost::mutex::scoped_lock sl(mMutex);
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ std::string SField::getName() const
|
||||
SField::ref SField::getField(const std::string& fieldName)
|
||||
{ // OPTIMIZEME me with a map. CHECKME this is case sensitive
|
||||
boost::mutex::scoped_lock sl(mapMutex);
|
||||
typedef std::pair<const int, SField::ptr> int_sfref_pair;
|
||||
typedef std::map<int, SField::ptr>::value_type int_sfref_pair;
|
||||
BOOST_FOREACH(const int_sfref_pair& fieldPair, codeToField)
|
||||
{
|
||||
if (fieldPair.second->fieldName == fieldName)
|
||||
|
||||
@@ -111,7 +111,7 @@ int JobQueue::getJobCountGE(JobType t)
|
||||
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
|
||||
typedef std::pair<JobType, int> jt_int_pair;
|
||||
typedef std::map<JobType, int>::value_type jt_int_pair;
|
||||
BOOST_FOREACH(const jt_int_pair& it, mJobCounts)
|
||||
if (it.first >= t)
|
||||
ret += it.second;
|
||||
@@ -125,7 +125,7 @@ std::vector< std::pair<JobType, int> > JobQueue::getJobCounts()
|
||||
boost::mutex::scoped_lock sl(mJobLock);
|
||||
ret.reserve(mJobCounts.size());
|
||||
|
||||
typedef std::pair<JobType, int> jt_int_pair;
|
||||
typedef std::map<JobType, int>::value_type jt_int_pair;
|
||||
BOOST_FOREACH(const jt_int_pair& it, mJobCounts)
|
||||
ret.push_back(it);
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
|
||||
#define LC_DEBUG
|
||||
|
||||
typedef std::pair<const uint160, LedgerProposal::pointer> u160_prop_pair;
|
||||
typedef std::pair<const uint256, LCTransaction::pointer> u256_lct_pair;
|
||||
typedef std::map<uint160, LedgerProposal::pointer>::value_type u160_prop_pair;
|
||||
typedef std::map<uint256, LCTransaction::pointer>::value_type u256_lct_pair;
|
||||
|
||||
SETUP_LOG();
|
||||
DECLARE_INSTANCE(LedgerConsensus);
|
||||
@@ -348,7 +348,7 @@ void LedgerConsensus::checkLCL()
|
||||
boost::unordered_map<uint256, currentValidationCount> vals =
|
||||
theApp->getValidations().getCurrentValidations(favoredLedger);
|
||||
|
||||
typedef std::pair<const uint256, currentValidationCount> u256_cvc_pair;
|
||||
typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair;
|
||||
BOOST_FOREACH(u256_cvc_pair& it, vals)
|
||||
if (it.second.first > netLgrCount)
|
||||
{
|
||||
@@ -471,7 +471,7 @@ void LedgerConsensus::createDisputes(SHAMap::ref m1, SHAMap::ref m2)
|
||||
SHAMap::SHAMapDiff differences;
|
||||
m1->compare(m2, differences, 16384);
|
||||
|
||||
typedef std::pair<const uint256, SHAMap::SHAMapDiffItem> u256_diff_pair;
|
||||
typedef std::map<uint256, SHAMap::SHAMapDiffItem>::value_type u256_diff_pair;
|
||||
BOOST_FOREACH (u256_diff_pair& pos, differences)
|
||||
{ // create disputed transactions (from the ledger that has them)
|
||||
if (pos.second.first)
|
||||
|
||||
@@ -366,7 +366,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result, uint32 index)
|
||||
// Entries modified only as a result of building the transaction metadata
|
||||
boost::unordered_map<uint256, SLE::pointer> newMod;
|
||||
|
||||
typedef std::pair<const uint256, LedgerEntrySetEntry> u256_LES_pair;
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::value_type u256_LES_pair;
|
||||
BOOST_FOREACH(u256_LES_pair& it, mEntries)
|
||||
{
|
||||
SField::ptr type = &sfGeneric;
|
||||
@@ -479,7 +479,7 @@ void LedgerEntrySet::calcRawMeta(Serializer& s, TER result, uint32 index)
|
||||
}
|
||||
|
||||
// add any new modified nodes to the modification set
|
||||
typedef std::pair<const uint256, SLE::pointer> u256_sle_pair;
|
||||
typedef std::map<uint256, SLE::pointer>::value_type u256_sle_pair;
|
||||
BOOST_FOREACH(u256_sle_pair& it, newMod)
|
||||
entryModify(it.second);
|
||||
|
||||
|
||||
@@ -570,7 +570,7 @@ bool NetworkOPs::checkLastClosedLedger(const std::vector<Peer::pointer>& peerLis
|
||||
{
|
||||
boost::unordered_map<uint256, currentValidationCount> current =
|
||||
theApp->getValidations().getCurrentValidations(closedLedger);
|
||||
typedef std::pair<const uint256, currentValidationCount> u256_cvc_pair;
|
||||
typedef std::map<uint256, currentValidationCount>::value_type u256_cvc_pair;
|
||||
BOOST_FOREACH(u256_cvc_pair& it, current)
|
||||
{
|
||||
ValidationCount& vc = ledgers[it.first];
|
||||
@@ -1152,8 +1152,8 @@ void NetworkOPs::pubAccountTransaction(Ledger::ref lpCurrent, const SerializedTr
|
||||
|
||||
if (!mSubAccount.empty() || (!mSubRTAccount.empty()) )
|
||||
{
|
||||
typedef const std::pair<RippleAddress,bool> AccountPair;
|
||||
BOOST_FOREACH(AccountPair& affectedAccount, getAffectedAccounts(stTxn))
|
||||
typedef std::map<RippleAddress, bool>::value_type AccountPair;
|
||||
BOOST_FOREACH(const AccountPair& affectedAccount, getAffectedAccounts(stTxn))
|
||||
{
|
||||
subInfoMapIterator simiIt = mSubRTAccount.find(affectedAccount.first.getAccountID());
|
||||
|
||||
|
||||
@@ -81,8 +81,8 @@ bool ParameterNode::addNode(const std::string& name, Parameter::ref node)
|
||||
Json::Value ParameterNode::getValue(int i) const
|
||||
{
|
||||
Json::Value v(Json::objectValue);
|
||||
typedef std::pair<std::string, Parameter::pointer> string_ref_pair;
|
||||
BOOST_FOREACH(string_ref_pair it, mChildren)
|
||||
typedef std::map<std::string, Parameter::pointer>::value_type string_ref_pair;
|
||||
BOOST_FOREACH(const string_ref_pair& it, mChildren)
|
||||
{
|
||||
v[it.first] = it.second->getValue(i);
|
||||
}
|
||||
@@ -95,8 +95,8 @@ bool ParameterNode::setValue(const Json::Value& value, Json::Value& error)
|
||||
error["error"] = "Cannot end on an inner node";
|
||||
|
||||
Json::Value nodes(Json::arrayValue);
|
||||
typedef std::pair<std::string, Parameter::pointer> string_ref_pair;
|
||||
BOOST_FOREACH(string_ref_pair it, mChildren)
|
||||
typedef std::map<std::string, Parameter::pointer>::value_type string_ref_pair;
|
||||
BOOST_FOREACH(const string_ref_pair& it, mChildren)
|
||||
{
|
||||
nodes.append(it.first);
|
||||
}
|
||||
|
||||
@@ -1565,7 +1565,7 @@ Json::Value RPCHandler::doLogLevel(Json::Value jvRequest)
|
||||
|
||||
lev["base"] = Log::severityToString(Log::getMinSeverity());
|
||||
std::vector< std::pair<std::string, std::string> > logTable = LogPartition::getSeverities();
|
||||
typedef std::pair<std::string, std::string> stringPair;
|
||||
typedef std::map<std::string, std::string>::value_type stringPair;
|
||||
BOOST_FOREACH(const stringPair& it, logTable)
|
||||
lev[it.first] = it.second;
|
||||
|
||||
|
||||
@@ -294,7 +294,7 @@ void STObject::add(Serializer& s, bool withSigningFields) const
|
||||
}
|
||||
|
||||
|
||||
typedef std::pair<const int, const SerializedType*> field_iterator;
|
||||
typedef std::map<int, const SerializedType*>::value_type field_iterator;
|
||||
BOOST_FOREACH(field_iterator& it, fields)
|
||||
{ // insert them in sorted order
|
||||
const SerializedType* field = it.second;
|
||||
|
||||
@@ -23,7 +23,7 @@ DECLARE_INSTANCE(TransactionEngine);
|
||||
void TransactionEngine::txnWrite()
|
||||
{
|
||||
// Write back the account states
|
||||
typedef std::pair<const uint256, LedgerEntrySetEntry> u256_LES_pair;
|
||||
typedef std::map<uint256, LedgerEntrySetEntry>::value_type u256_LES_pair;
|
||||
BOOST_FOREACH(u256_LES_pair& it, mNodes)
|
||||
{
|
||||
const SLE::pointer& sleEntry = it.second.mEntry;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
SETUP_LOG();
|
||||
|
||||
typedef std::pair<const uint160, SerializedValidation::pointer> u160_val_pair;
|
||||
typedef std::map<uint160, SerializedValidation::pointer>::value_type u160_val_pair;
|
||||
typedef boost::shared_ptr<ValidationSet> VSpointer;
|
||||
|
||||
VSpointer ValidationCollection::findCreateSet(const uint256& ledgerHash)
|
||||
|
||||
@@ -48,8 +48,8 @@ std::string createHTTPPost(const std::string& strMsg, const std::map<std::string
|
||||
<< "Content-Length: " << strMsg.size() << "\r\n"
|
||||
<< "Accept: application/json\r\n";
|
||||
|
||||
typedef const std::pair<std::string, std::string> HeaderType;
|
||||
BOOST_FOREACH(HeaderType& item, mapRequestHeaders)
|
||||
typedef std::map<std::string, std::string>::value_type HeaderType;
|
||||
BOOST_FOREACH(const HeaderType& item, mapRequestHeaders)
|
||||
s << item.first << ": " << item.second << "\r\n";
|
||||
s << "\r\n" << strMsg;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user