diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
commit | bf452cbc2ae2b209ec262ce858deca470d086f24 (patch) | |
tree | 198e98902be569301ecb9a821b0c9512b128f930 /third_party/nix/src/nix/doctor.cc | |
parent | b99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (diff) |
refactor(3p/nix): Replace tokenizeStrings with absl::StrSplit r/846
This function was a custom (and inefficient in the case of single-character delimiters) string splitter which was used all over the codebase. Abseil provides an appropriate replacement function.
Diffstat (limited to 'third_party/nix/src/nix/doctor.cc')
-rw-r--r-- | third_party/nix/src/nix/doctor.cc | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/third_party/nix/src/nix/doctor.cc b/third_party/nix/src/nix/doctor.cc index 79e9eb5394e7..c7d133fdacf3 100644 --- a/third_party/nix/src/nix/doctor.cc +++ b/third_party/nix/src/nix/doctor.cc @@ -1,4 +1,6 @@ #include <absl/strings/match.h> +#include <absl/strings/str_cat.h> +#include <absl/strings/str_split.h> #include "command.hh" #include "serve-protocol.hh" @@ -46,9 +48,9 @@ struct CmdDoctor : StoreCommand { static bool checkNixInPath() { PathSet dirs; - for (auto& dir : tokenizeString<Strings>(getEnv("PATH"), ":")) { - if (pathExists(dir + "/nix-env")) { - dirs.insert(dirOf(canonPath(dir + "/nix-env", true))); + for (auto& dir : absl::StrSplit(getEnv("PATH"), absl::ByChar(':'))) { + if (pathExists(absl::StrCat(dir, "/nix-env"))) { + dirs.insert(dirOf(canonPath(absl::StrCat(dir, "/nix-env"), true))); } } @@ -69,7 +71,7 @@ struct CmdDoctor : StoreCommand { static bool checkProfileRoots(const ref<Store>& store) { PathSet dirs; - for (auto& dir : tokenizeString<Strings>(getEnv("PATH"), ":")) { + for (auto dir : absl::StrSplit(getEnv("PATH"), absl::ByChar(':'))) { Path profileDir = dirOf(dir); try { Path userEnv = canonPath(profileDir, true); @@ -82,7 +84,7 @@ struct CmdDoctor : StoreCommand { } if (profileDir.find("/profiles/") == std::string::npos) { - dirs.insert(dir); + dirs.insert(std::string(dir)); } } } catch (SysError&) { |