mirror of
https://github.com/NixOS/nix.git
synced 2025-11-13 22:12:43 +01:00
fix(treewide): remove unnecessary copying in range for loops
This gets rid of unnecessary copies in range-based-for loops and local variables, when they are used solely as `const &`. Also added a fixme comment about a suspicious move out of const, which might not be intended.
This commit is contained in:
parent
4fc5295328
commit
fafaec5ac3
20 changed files with 25 additions and 24 deletions
|
|
@ -32,7 +32,7 @@ Goal::Co DrvOutputSubstitutionGoal::init()
|
|||
|
||||
bool substituterFailed = false;
|
||||
|
||||
for (auto sub : subs) {
|
||||
for (const auto & sub : subs) {
|
||||
trace("trying next substituter");
|
||||
|
||||
/* The callback of the curl download below can outlive `this` (if
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ Goal::Co PathSubstitutionGoal::init()
|
|||
|
||||
bool substituterFailed = false;
|
||||
|
||||
for (auto sub : subs) {
|
||||
for (const auto & sub : subs) {
|
||||
trace("trying next substituter");
|
||||
|
||||
cleanup();
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ PublicKeys getDefaultPublicKeys()
|
|||
|
||||
// FIXME: filter duplicates
|
||||
|
||||
for (auto s : settings.trustedPublicKeys.get()) {
|
||||
for (const auto & s : settings.trustedPublicKeys.get()) {
|
||||
PublicKey key(s);
|
||||
publicKeys.emplace(key.name, key);
|
||||
}
|
||||
|
||||
for (auto secretKeyFile : settings.secretKeyFiles.get()) {
|
||||
for (const auto & secretKeyFile : settings.secretKeyFiles.get()) {
|
||||
try {
|
||||
SecretKey secretKey(readFile(secretKeyFile));
|
||||
publicKeys.emplace(secretKey.name, secretKey.toPublicKey());
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ void LocalOverlayStore::queryGCReferrers(const StorePath & path, StorePathSet &
|
|||
StorePathSet LocalOverlayStore::queryValidDerivers(const StorePath & path)
|
||||
{
|
||||
auto res = LocalStore::queryValidDerivers(path);
|
||||
for (auto p : lowerStore->queryValidDerivers(path))
|
||||
for (const auto & p : lowerStore->queryValidDerivers(path))
|
||||
res.insert(p);
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ std::string NarInfo::to_string(const Store & store) const
|
|||
if (deriver)
|
||||
res += "Deriver: " + std::string(deriver->to_string()) + "\n";
|
||||
|
||||
for (auto sig : sigs)
|
||||
for (const auto & sig : sigs)
|
||||
res += "Sig: " + sig + "\n";
|
||||
|
||||
if (ca)
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ struct S3BinaryCacheStoreImpl : virtual S3BinaryCacheStoreConfig, public virtual
|
|||
debug("got %d keys, next marker '%s'",
|
||||
contents.size(), res.GetNextMarker());
|
||||
|
||||
for (auto object : contents) {
|
||||
for (const auto & object : contents) {
|
||||
auto & key = object.GetKey();
|
||||
if (key.size() != 40 || !hasSuffix(key, ".narinfo")) continue;
|
||||
paths.insert(parseStorePath(storeDir + "/" + key.substr(0, key.size() - 8) + "-" + MissingName));
|
||||
|
|
|
|||
|
|
@ -1332,7 +1332,7 @@ ref<Store> openStore(StoreReference && storeURI)
|
|||
return std::make_shared<LocalStore>(params);
|
||||
},
|
||||
[&](const StoreReference::Specified & g) {
|
||||
for (auto implem : *Implementations::registered)
|
||||
for (const auto & implem : *Implementations::registered)
|
||||
if (implem.uriSchemes.count(g.scheme))
|
||||
return implem.create(g.scheme, g.authority, params);
|
||||
|
||||
|
|
@ -1363,7 +1363,7 @@ std::list<ref<Store>> getDefaultSubstituters()
|
|||
}
|
||||
};
|
||||
|
||||
for (auto uri : settings.substituters.get())
|
||||
for (const auto & uri : settings.substituters.get())
|
||||
addStore(uri);
|
||||
|
||||
stores.sort([](ref<Store> & a, ref<Store> & b) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue