From 43677021e3c285c2ced2075b918da947e13fcb00 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Wed, 20 May 2020 22:58:43 +0100 Subject: refactor(3p/nix): Apply clang-tidy's performance-* fixes This applies the performance fixes listed here: https://clang.llvm.org/extra/clang-tidy/checks/list.html --- third_party/nix/src/libmain/common-args.cc | 2 +- third_party/nix/src/libmain/shared.cc | 12 +++++++----- third_party/nix/src/libmain/shared.hh | 7 ++++--- 3 files changed, 12 insertions(+), 9 deletions(-) (limited to 'third_party/nix/src/libmain') diff --git a/third_party/nix/src/libmain/common-args.cc b/third_party/nix/src/libmain/common-args.cc index 9d6f6445c0e7..3d9b8ebfaefd 100644 --- a/third_party/nix/src/libmain/common-args.cc +++ b/third_party/nix/src/libmain/common-args.cc @@ -26,7 +26,7 @@ MixCommonArgs::MixCommonArgs(const string& programName) .shortName('j') .label("jobs") .description("maximum number of parallel builds") - .handler([=](std::string s) { settings.set("max-jobs", s); }); + .handler([=](const std::string& s) { settings.set("max-jobs", s); }); std::string cat = "config"; globalConfig.convertToArgs(*this, cat); 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, const PathSet& paths) { +void printMissing(const ref& store, const PathSet& paths) { unsigned long long downloadSize; unsigned long long narSize; PathSet willBuild; @@ -48,7 +48,7 @@ void printMissing(ref store, const PathSet& paths) { narSize); } -void printMissing(ref store, const PathSet& willBuild, +void printMissing(const ref& 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 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 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 fun) { +int handleExceptions(const string& programName, + const std::function& fun) { ReceiveInterrupts receiveInterrupts; // FIXME: need better place for this string error = ANSI_RED "error:" ANSI_NORMAL " "; diff --git a/third_party/nix/src/libmain/shared.hh b/third_party/nix/src/libmain/shared.hh index db236a701778..da1c9cc66ac3 100644 --- a/third_party/nix/src/libmain/shared.hh +++ b/third_party/nix/src/libmain/shared.hh @@ -18,7 +18,8 @@ class Exit : public std::exception { virtual ~Exit(); }; -int handleExceptions(const string& programName, std::function fun); +int handleExceptions(const string& programName, + const std::function& fun); /* Don't forget to call initPlugins() after settings are initialized! */ void initNix(); @@ -40,9 +41,9 @@ void printGCWarning(); class Store; -void printMissing(ref store, const PathSet& paths); +void printMissing(const ref& store, const PathSet& paths); -void printMissing(ref store, const PathSet& willBuild, +void printMissing(const ref& store, const PathSet& willBuild, const PathSet& willSubstitute, const PathSet& unknown, unsigned long long downloadSize, unsigned long long narSize); -- cgit 1.4.1