about summary refs log tree commit diff
path: root/third_party/nix/src/libmain/shared.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/libmain/shared.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/libmain/shared.cc')
-rw-r--r--third_party/nix/src/libmain/shared.cc12
1 files changed, 7 insertions, 5 deletions
diff --git a/third_party/nix/src/libmain/shared.cc b/third_party/nix/src/libmain/shared.cc
index 5c2084691144..f6c80cae30ef 100644
--- a/third_party/nix/src/libmain/shared.cc
+++ b/third_party/nix/src/libmain/shared.cc
@@ -36,7 +36,7 @@ void printGCWarning() {
   }
 }
 
-void printMissing(ref<Store> store, const PathSet& paths) {
+void printMissing(const ref<Store>& store, const PathSet& paths) {
   unsigned long long downloadSize;
   unsigned long long narSize;
   PathSet willBuild;
@@ -48,7 +48,7 @@ void printMissing(ref<Store> store, const PathSet& paths) {
                narSize);
 }
 
-void printMissing(ref<Store> store, const PathSet& willBuild,
+void printMissing(const ref<Store>& store, const PathSet& willBuild,
                   const PathSet& willSubstitute, const PathSet& unknown,
                   unsigned long long downloadSize, unsigned long long narSize) {
   if (!willBuild.empty()) {
@@ -260,14 +260,15 @@ void parseCmdLine(
     int argc, char** argv,
     std::function<bool(Strings::iterator& arg, const Strings::iterator& end)>
         parseArg) {
-  parseCmdLine(baseNameOf(argv[0]), argvToStrings(argc, argv), parseArg);
+  parseCmdLine(baseNameOf(argv[0]), argvToStrings(argc, argv),
+               std::move(parseArg));
 }
 
 void parseCmdLine(
     const string& programName, const Strings& args,
     std::function<bool(Strings::iterator& arg, const Strings::iterator& end)>
         parseArg) {
-  LegacyArgs(programName, parseArg).parseCmdline(args);
+  LegacyArgs(programName, std::move(parseArg)).parseCmdline(args);
 }
 
 void printVersion(const string& programName) {
@@ -298,7 +299,8 @@ void showManPage(const string& name) {
   throw SysError(format("command 'man %1%' failed") % name.c_str());
 }
 
-int handleExceptions(const string& programName, std::function<void()> fun) {
+int handleExceptions(const string& programName,
+                     const std::function<void()>& fun) {
   ReceiveInterrupts receiveInterrupts;  // FIXME: need better place for this
 
   string error = ANSI_RED "error:" ANSI_NORMAL " ";