about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/store-api.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-20T21·58+0100
committerVincent Ambo <tazjin@google.com>2020-05-20T21·58+0100
commit43677021e3c285c2ced2075b918da947e13fcb00 (patch)
tree261d2ecbc6a9492d6410f9f4e8fd6629f20b49e6 /third_party/nix/src/libstore/store-api.cc
parent689ef502f5b0655c9923ed77da2ae3504630f473 (diff)
refactor(3p/nix): Apply clang-tidy's performance-* fixes r/789
This applies the performance fixes listed here:

https://clang.llvm.org/extra/clang-tidy/checks/list.html
Diffstat (limited to 'third_party/nix/src/libstore/store-api.cc')
-rw-r--r--third_party/nix/src/libstore/store-api.cc17
1 files changed, 9 insertions, 8 deletions
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc
index 39cb5ca9f6..50e9b3b6ea 100644
--- a/third_party/nix/src/libstore/store-api.cc
+++ b/third_party/nix/src/libstore/store-api.cc
@@ -1,6 +1,7 @@
 #include "store-api.hh"
 
 #include <future>
+#include <utility>
 
 #include <glog/logging.h>
 
@@ -570,7 +571,7 @@ void Store::buildPaths(const PathSet& paths, BuildMode buildMode) {
   }
 }
 
-void copyStorePath(ref<Store> srcStore, ref<Store> dstStore,
+void copyStorePath(ref<Store> srcStore, const ref<Store>& dstStore,
                    const Path& storePath, RepairFlag repair,
                    CheckSigsFlag checkSigs) {
   auto srcUri = srcStore->getUri();
@@ -693,7 +694,7 @@ void copyPaths(ref<Store> srcStore, ref<Store> dstStore,
       });
 }
 
-void copyClosure(ref<Store> srcStore, ref<Store> dstStore,
+void copyClosure(const ref<Store>& srcStore, const ref<Store>& dstStore,
                  const PathSet& storePaths, RepairFlag repair,
                  CheckSigsFlag checkSigs, SubstituteFlag substitute) {
   PathSet closure;
@@ -824,14 +825,14 @@ void Store::addToStore(const ValidPathInfo& info, Source& narSource,
                        RepairFlag repair, CheckSigsFlag checkSigs,
                        std::shared_ptr<FSAccessor> accessor) {
   addToStore(info, make_ref<std::string>(narSource.drain()), repair, checkSigs,
-             accessor);
+             std::move(accessor));
 }
 
 void Store::addToStore(const ValidPathInfo& info, const ref<std::string>& nar,
                        RepairFlag repair, CheckSigsFlag checkSigs,
                        std::shared_ptr<FSAccessor> accessor) {
   StringSource source(*nar);
-  addToStore(info, source, repair, checkSigs, accessor);
+  addToStore(info, source, repair, checkSigs, std::move(accessor));
 }
 
 }  // namespace nix
@@ -851,7 +852,7 @@ std::pair<std::string, Store::Params> splitUriAndParams(
   Store::Params params;
   auto q = uri.find('?');
   if (q != std::string::npos) {
-    for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
+    for (const auto& s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
       auto e = s.find('=');
       if (e != std::string::npos) {
         auto value = s.substr(e + 1);
@@ -885,7 +886,7 @@ ref<Store> openStore(const std::string& uri_,
   auto params = extraParams;
   params.insert(uriParams.begin(), uriParams.end());
 
-  for (auto fun : *RegisterStoreImplementation::implementations) {
+  for (const auto& fun : *RegisterStoreImplementation::implementations) {
     auto store = fun(uri, params);
     if (store) {
       store->warnUnknownSettings();
@@ -952,11 +953,11 @@ std::list<ref<Store>> getDefaultSubstituters() {
       }
     };
 
-    for (auto uri : settings.substituters.get()) {
+    for (const auto& uri : settings.substituters.get()) {
       addStore(uri);
     }
 
-    for (auto uri : settings.extraSubstituters.get()) {
+    for (const auto& uri : settings.extraSubstituters.get()) {
       addStore(uri);
     }