Use emplace where we can. (On inserts into unordered maps.)

This commit is contained in:
JoelKatz
2013-03-11 03:58:27 -07:00
parent f3b837eea6
commit f4e22a8968
4 changed files with 12 additions and 12 deletions

View File

@@ -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;
}