use const refs in for loops for non tiny types

release-v0.4.0.1
moneromooo-monero 7 years ago
parent f0568ca6ac
commit b51dc56687
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

@ -459,7 +459,7 @@ int import_from_file(cryptonote::core& core, const std::string& import_file_path
// tx number 1: coinbase tx // tx number 1: coinbase tx
// tx number 2 onwards: archived_txs // tx number 2 onwards: archived_txs
for (transaction tx : archived_txs) for (const transaction &tx : archived_txs)
{ {
// add blocks with verification. // add blocks with verification.
// for Blockchain and blockchain_storage add_new_block(). // for Blockchain and blockchain_storage add_new_block().

@ -385,7 +385,7 @@ float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
i->second = (i->second + span.rate) / 2; i->second = (i->second + span.rate) / 2;
} }
float conn_rate = -1, best_rate = 0; float conn_rate = -1, best_rate = 0;
for (auto i: speeds) for (const auto &i: speeds)
{ {
if (i.first == connection_id) if (i.first == connection_id)
conn_rate = i.second; conn_rate = i.second;

@ -1611,7 +1611,7 @@ bool t_rpc_command_executor::alt_chain_info()
} }
tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:"; tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:";
for (const auto chain: res.chains) for (const auto &chain: res.chains)
{ {
uint64_t start_height = (chain.height - chain.length + 1); uint64_t start_height = (chain.height - chain.length + 1);
tools::msg_writer() << chain.length << " blocks long, from height " << start_height << " (" << (ires.height - start_height - 1) tools::msg_writer() << chain.length << " blocks long, from height " << start_height << " (" << (ires.height - start_height - 1)

@ -51,7 +51,7 @@ class size_logger
public: public:
~size_logger() ~size_logger()
{ {
for (const auto i: types) for (const auto &i: types)
std::cout << std::to_string(i.first) << "\t" << i.second << std::endl; std::cout << std::to_string(i.first) << "\t" << i.second << std::endl;
} }
void add(const char *type, size_t size) { types.insert(std::make_pair(size, type)); } void add(const char *type, size_t size) { types.insert(std::make_pair(size, type)); }

@ -5126,7 +5126,7 @@ void wallet2::get_outs(std::vector<std::vector<tools::wallet2::get_outs_entry>>
// if there are just enough outputs to mix with, use all of them. // if there are just enough outputs to mix with, use all of them.
// Eventually this should become impossible. // Eventually this should become impossible.
uint64_t num_outs = 0, num_recent_outs = 0; uint64_t num_outs = 0, num_recent_outs = 0;
for (auto he: resp_t.result.histogram) for (const auto &he: resp_t.result.histogram)
{ {
if (he.amount == amount) if (he.amount == amount)
{ {

Loading…
Cancel
Save