mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-28 23:15:52 +00:00
Use emplace where we can. (On inserts into unordered maps.)
This commit is contained in:
@@ -1676,7 +1676,7 @@ bool NetworkOPs::subLedger(InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
jvResult["validated_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers();
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||
return mSubLedger.insert(std::make_pair(isrListener->getSeq(), isrListener)).second;
|
||||
return mSubLedger.emplace(isrListener->getSeq(), isrListener).second;
|
||||
}
|
||||
|
||||
// <-- bool: true=erased, false=was not there
|
||||
@@ -1704,7 +1704,7 @@ bool NetworkOPs::subServer(InfoSub::ref isrListener, Json::Value& jvResult)
|
||||
jvResult["load_factor"] = theApp->getFeeTrack().getLoadFactor();
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||
return mSubServer.insert(std::make_pair(isrListener->getSeq(), isrListener)).second;
|
||||
return mSubServer.emplace(isrListener->getSeq(), isrListener).second;
|
||||
}
|
||||
|
||||
// <-- bool: true=erased, false=was not there
|
||||
@@ -1718,7 +1718,7 @@ bool NetworkOPs::unsubServer(uint64 uSeq)
|
||||
bool NetworkOPs::subTransactions(InfoSub::ref isrListener)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||
return mSubTransactions.insert(std::make_pair(isrListener->getSeq(), isrListener)).second;
|
||||
return mSubTransactions.emplace(isrListener->getSeq(), isrListener).second;
|
||||
}
|
||||
|
||||
// <-- bool: true=erased, false=was not there
|
||||
@@ -1732,7 +1732,7 @@ bool NetworkOPs::unsubTransactions(uint64 uSeq)
|
||||
bool NetworkOPs::subRTTransactions(InfoSub::ref isrListener)
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||
return mSubTransactions.insert(std::make_pair(isrListener->getSeq(), isrListener)).second;
|
||||
return mSubTransactions.emplace(isrListener->getSeq(), isrListener).second;
|
||||
}
|
||||
|
||||
// <-- bool: true=erased, false=was not there
|
||||
@@ -1756,7 +1756,7 @@ InfoSub::pointer NetworkOPs::addRpcSub(const std::string& strUrl, InfoSub::ref r
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
|
||||
|
||||
mRpcSubMap.insert(std::make_pair(strUrl, rspEntry));
|
||||
mRpcSubMap.emplace(strUrl, rspEntry);
|
||||
|
||||
return rspEntry;
|
||||
}
|
||||
|
||||
@@ -610,7 +610,7 @@ bool SHAMap::addGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMeta)
|
||||
assert(node->isEmptyBranch(branch));
|
||||
SHAMapTreeNode::pointer newNode =
|
||||
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(branch), item, type, mSeq);
|
||||
if (!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||
if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second)
|
||||
{
|
||||
std::cerr << "Node: " << *node << std::endl;
|
||||
std::cerr << "NewNode: " << *newNode << std::endl;
|
||||
@@ -643,7 +643,7 @@ bool SHAMap::addGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMeta)
|
||||
SHAMapTreeNode::pointer newNode =
|
||||
boost::make_shared<SHAMapTreeNode>(mSeq, node->getChildNodeID(b1));
|
||||
newNode->makeInner();
|
||||
if (!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||
if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second)
|
||||
assert(false);
|
||||
stack.push(node);
|
||||
node = newNode;
|
||||
@@ -655,14 +655,14 @@ bool SHAMap::addGiveItem(SHAMapItem::ref item, bool isTransaction, bool hasMeta)
|
||||
SHAMapTreeNode::pointer newNode =
|
||||
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b1), item, type, mSeq);
|
||||
assert(newNode->isValid() && newNode->isLeaf());
|
||||
if (!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||
if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second)
|
||||
assert(false);
|
||||
node->setChildHash(b1, newNode->getNodeHash()); // OPTIMIZEME hash op not needed
|
||||
trackNewNode(newNode);
|
||||
|
||||
newNode = boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b2), otherItem, type, mSeq);
|
||||
assert(newNode->isValid() && newNode->isLeaf());
|
||||
if (!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||
if (!mTNByID.emplace(SHAMapNode(*newNode), newNode).second)
|
||||
assert(false);
|
||||
node->setChildHash(b2, newNode->getNodeHash());
|
||||
trackNewNode(newNode);
|
||||
@@ -744,7 +744,7 @@ SHAMapTreeNode::pointer SHAMap::fetchNodeExternal(const SHAMapNode& id, const ui
|
||||
}
|
||||
if (id.isRoot())
|
||||
mTNByID[id] = ret;
|
||||
else if (!mTNByID.insert(std::make_pair(id, ret)).second)
|
||||
else if (!mTNByID.emplace(id, ret).second)
|
||||
assert(false);
|
||||
trackNewNode(ret);
|
||||
return ret;
|
||||
|
||||
@@ -30,7 +30,7 @@ Suppression& SuppressionTable::findCreateEntry(const uint256& index, bool& creat
|
||||
}
|
||||
|
||||
mSuppressionTimes[now].push_back(index);
|
||||
return mSuppressionMap.insert(std::make_pair(index, Suppression())).first->second;
|
||||
return mSuppressionMap.emplace(index, Suppression()).first->second;
|
||||
}
|
||||
|
||||
bool SuppressionTable::addSuppression(const uint256& index)
|
||||
|
||||
@@ -66,7 +66,7 @@ bool ValidationCollection::addValidation(SerializedValidation::ref val)
|
||||
{
|
||||
boost::unordered_map<uint160, SerializedValidation::pointer>::iterator it = mCurrentValidations.find(node);
|
||||
if (it == mCurrentValidations.end())
|
||||
mCurrentValidations.insert(std::make_pair(node, val));
|
||||
mCurrentValidations.emplace(node, val);
|
||||
else if (!it->second)
|
||||
it->second = val;
|
||||
else if (val->getSignTime() > it->second->getSignTime())
|
||||
|
||||
Reference in New Issue
Block a user