Make objects in range declarations immutable by default. Avoid unnecessary copying of objects in range declarations.

This commit is contained in:
practicalswift
2018-06-18 07:58:28 +02:00
parent f180e81d57
commit f34c8c466a
36 changed files with 77 additions and 77 deletions

View File

@ -82,11 +82,11 @@ static double test_cache(size_t megabytes, double load)
*/
std::vector<uint256> hashes_insert_copy = hashes;
/** Do the insert */
for (uint256& h : hashes_insert_copy)
for (const uint256& h : hashes_insert_copy)
set.insert(h);
/** Count the hits */
uint32_t count = 0;
for (uint256& h : hashes)
for (const uint256& h : hashes)
count += set.contains(h, false);
double hit_rate = ((double)count) / ((double)n_insert);
return hit_rate;
@ -323,7 +323,7 @@ static void test_cache_generations()
reads.push_back(inserts[i]);
for (uint32_t i = n_insert - (n_insert / 4); i < n_insert; ++i)
reads.push_back(inserts[i]);
for (auto h : inserts)
for (const auto& h : inserts)
c.insert(h);
}
};