Use structured bindings in some places:

Most of the new uses either:
* Replace some uses of `tie`
* bind to pairs when iterating through maps
This commit is contained in:
seelabs
2019-08-06 09:11:32 -07:00
parent 9c58f23cf8
commit 7912ee6f7b
66 changed files with 428 additions and 466 deletions

View File

@@ -226,10 +226,10 @@ public:
saveDot(std::ostream & out, VertexName&& vertexName) const
{
out << "digraph {\n";
for (auto const& vData : graph_)
for (auto const& [vertex, links] : graph_)
{
auto const fromName = vertexName(vData.first);
for (auto const& eData : vData.second)
auto const fromName = vertexName(vertex);
for (auto const& eData : links)
{
auto const toName = vertexName(eData.first);
out << fromName << " -> " << toName << ";\n";

View File

@@ -91,9 +91,9 @@ public:
return tmp;
// Since counts are sorted, shouldn't need to worry much about numerical
// error
for (auto const& it : counts_)
for (auto const& [bin, count] : counts_)
{
tmp += it.first * it.second;
tmp += bin * count;
}
return tmp/samples;
}

View File

@@ -801,11 +801,11 @@ struct Peer
bool
handle(TxSet const& txs)
{
auto const it = txSets.insert(std::make_pair(txs.id(), txs));
if (it.second)
bool const inserted = txSets.insert(std::make_pair(txs.id(), txs)).second;
if (inserted)
consensus.gotTxSet(now(), txs);
// relay only if new
return it.second;
return inserted;
}
bool