diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·58+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-20T21·58+0100 |
commit | 43677021e3c285c2ced2075b918da947e13fcb00 (patch) | |
tree | 261d2ecbc6a9492d6410f9f4e8fd6629f20b49e6 /third_party/nix/src/nix/repl.cc | |
parent | 689ef502f5b0655c9923ed77da2ae3504630f473 (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/nix/repl.cc')
-rw-r--r-- | third_party/nix/src/nix/repl.cc | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/third_party/nix/src/nix/repl.cc b/third_party/nix/src/nix/repl.cc index 81e940dd3aaf..78991645ac07 100644 --- a/third_party/nix/src/nix/repl.cc +++ b/third_party/nix/src/nix/repl.cc @@ -3,6 +3,7 @@ #include <cstdlib> #include <cstring> #include <iostream> +#include <utility> #include <glog/logging.h> @@ -58,10 +59,10 @@ struct NixRepl { const Path historyFile; - NixRepl(const Strings& searchPath, nix::ref<Store> store); + NixRepl(const Strings& searchPath, const nix::ref<Store>& store); ~NixRepl(); void mainLoop(const std::vector<std::string>& files); - StringSet completePrefix(string prefix); + StringSet completePrefix(const string& prefix); static bool getLine(string& input, const std::string& prompt); Path getDerivationPath(Value& v); bool processLine(string line); @@ -70,7 +71,7 @@ struct NixRepl { void reloadFiles(); void addAttrsToScope(Value& attrs); void addVarToScope(const Symbol& name, Value& v); - Expr* parseString(string s); + Expr* parseString(const string& s); void evalString(string s, Value& v); using ValuesSeen = set<Value*>; @@ -129,7 +130,7 @@ string removeWhitespace(string s) { return s; } -NixRepl::NixRepl(const Strings& searchPath, nix::ref<Store> store) +NixRepl::NixRepl(const Strings& searchPath, const nix::ref<Store>& store) : state(searchPath, store), staticEnv(false, &state.staticBaseEnv), historyFile(getDataDir() + "/nix/repl-history") { @@ -332,7 +333,7 @@ bool NixRepl::getLine(string& input, const std::string& prompt) { return true; } -StringSet NixRepl::completePrefix(string prefix) { +StringSet NixRepl::completePrefix(const string& prefix) { StringSet completions; size_t start = prefix.find_last_of(" \n\r\t(){}[]"); @@ -641,13 +642,13 @@ void NixRepl::addVarToScope(const Symbol& name, Value& v) { varNames.insert((string)name); } -Expr* NixRepl::parseString(string s) { +Expr* NixRepl::parseString(const string& s) { Expr* e = state.parseExprFromString(s, curDir, staticEnv); return e; } void NixRepl::evalString(string s, Value& v) { - Expr* e = parseString(s); + Expr* e = parseString(std::move(s)); e->eval(state, *env, v); state.forceValue(v); } |