mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Use forward_tuple to prevent needless copies
This commit is contained in:
@@ -183,8 +183,8 @@ public:
|
||||
lock_guard lock (m_mutex);
|
||||
clock_type::time_point const now (m_clock.now ());
|
||||
std::pair <iterator, bool> result (m_map.emplace (
|
||||
std::piecewise_construct, std::make_tuple (key),
|
||||
std::make_tuple (now)));
|
||||
std::piecewise_construct, std::forward_as_tuple (key),
|
||||
std::forward_as_tuple (now)));
|
||||
if (! result.second)
|
||||
{
|
||||
result.first->second.last_access = now;
|
||||
|
||||
@@ -172,7 +172,7 @@ public:
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
typedef boost::unordered_map <IP::Endpoint, Entry> Entries;
|
||||
typedef std::unordered_map <IP::Endpoint, Entry> Entries;
|
||||
|
||||
typedef std::vector <Entries::iterator> SortedEntries;
|
||||
|
||||
@@ -217,8 +217,9 @@ public:
|
||||
iter != list.end(); ++iter)
|
||||
{
|
||||
std::pair <Entries::iterator, bool> result (
|
||||
m_entries.emplace (boost::unordered::piecewise_construct,
|
||||
boost::make_tuple (iter->address), boost::make_tuple ()));
|
||||
m_entries.emplace (std::piecewise_construct,
|
||||
std::forward_as_tuple (iter->address),
|
||||
std::make_tuple ()));
|
||||
if (result.second)
|
||||
{
|
||||
++count;
|
||||
@@ -286,8 +287,9 @@ public:
|
||||
bool insert (IP::Endpoint const& address)
|
||||
{
|
||||
std::pair <Entries::iterator, bool> result (
|
||||
m_entries.emplace (boost::unordered::piecewise_construct,
|
||||
boost::make_tuple (address), boost::make_tuple ()));
|
||||
m_entries.emplace (std::piecewise_construct,
|
||||
std::forward_as_tuple (address),
|
||||
std::make_tuple ()));
|
||||
if (result.second)
|
||||
{
|
||||
if (m_journal.trace) m_journal.trace << leftw (18) <<
|
||||
@@ -331,8 +333,9 @@ public:
|
||||
HandshakeAction action)
|
||||
{
|
||||
std::pair <Entries::iterator, bool> result (
|
||||
m_entries.emplace (boost::unordered::piecewise_construct,
|
||||
boost::make_tuple (address), boost::make_tuple ()));
|
||||
m_entries.emplace (std::piecewise_construct,
|
||||
std::forward_as_tuple (address),
|
||||
std::make_tuple ()));
|
||||
Entry& entry (result.first->second);
|
||||
// Can't already be active!
|
||||
consistency_check (! entry.active);
|
||||
@@ -371,8 +374,9 @@ public:
|
||||
void onConnectionActive (IP::Endpoint const& address)
|
||||
{
|
||||
std::pair <Entries::iterator, bool> result (
|
||||
m_entries.emplace (boost::unordered::piecewise_construct,
|
||||
boost::make_tuple (address), boost::make_tuple ()));
|
||||
m_entries.emplace (std::piecewise_construct,
|
||||
std::forward_as_tuple (address),
|
||||
std::make_tuple ()));
|
||||
// Must exist!
|
||||
consistency_check (! result.second);
|
||||
Entry& entry (result.first->second);
|
||||
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
for (auto remote_address : addresses)
|
||||
{
|
||||
auto result (state->fixed.emplace (std::piecewise_construct,
|
||||
std::make_tuple (remote_address),
|
||||
std::forward_as_tuple (remote_address),
|
||||
std::make_tuple (std::ref (m_clock))));
|
||||
|
||||
if (result.second)
|
||||
|
||||
@@ -1828,7 +1828,11 @@ std::vector<NetworkOPsImp::txnMetaLedgerType> NetworkOPsImp::getAccountTxsB (
|
||||
else
|
||||
rawMeta.resize (metaSize);
|
||||
|
||||
ret.push_back (boost::make_tuple (strHex (rawTxn), strHex (rawMeta), db->getInt ("LedgerSeq")));
|
||||
// VFALCO TODO Change the container's type to be std::tuple so
|
||||
// we can use std::forward_as_tuple here
|
||||
//
|
||||
ret.push_back (boost::make_tuple (
|
||||
strHex (rawTxn), strHex (rawMeta), db->getInt ("LedgerSeq")));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2039,7 +2043,8 @@ NetworkOPsImp::getTxsAccountB (const RippleAddress& account, int32 minLedger, in
|
||||
else
|
||||
rawMeta.resize (metaSize);
|
||||
|
||||
ret.push_back (boost::make_tuple (strHex (rawTxn), strHex (rawMeta), db->getInt ("LedgerSeq")));
|
||||
ret.push_back (boost::make_tuple (
|
||||
strHex (rawTxn), strHex (rawMeta), db->getInt ("LedgerSeq")));
|
||||
--numberOfResults;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ private:
|
||||
{
|
||||
std::pair <Map::iterator, bool> result (
|
||||
m_map.emplace (std::piecewise_construct,
|
||||
std::make_tuple (code), std::make_tuple (
|
||||
std::forward_as_tuple (code), std::forward_as_tuple (
|
||||
code, token, message)));
|
||||
if (! result.second)
|
||||
throw std::invalid_argument ("duplicate error code");
|
||||
|
||||
@@ -42,8 +42,8 @@ public:
|
||||
void add (std::string const& method, handler_type&& handler)
|
||||
{
|
||||
std::pair <Map::iterator, bool> result (m_map.emplace (
|
||||
std::piecewise_construct, std::make_tuple (method),
|
||||
std::make_tuple (std::move (handler))));
|
||||
std::piecewise_construct, std::forward_as_tuple (method),
|
||||
std::forward_as_tuple (std::move (handler))));
|
||||
}
|
||||
|
||||
bool dispatch (Request& req)
|
||||
|
||||
Reference in New Issue
Block a user