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-build | |
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-build')
-rw-r--r-- | third_party/nix/src/nix-build/nix-build.cc | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/third_party/nix/src/nix-build/nix-build.cc b/third_party/nix/src/nix-build/nix-build.cc index 6906a805830e..938452f71667 100644 --- a/third_party/nix/src/nix-build/nix-build.cc +++ b/third_party/nix/src/nix-build/nix-build.cc @@ -6,6 +6,7 @@ #include <vector> #include <absl/strings/ascii.h> +#include <absl/strings/str_split.h> #include <glog/logging.h> #include "affinity.hh" @@ -113,7 +114,7 @@ static void _main(int argc, char** argv) { !std::regex_search(argv[1], std::regex("nix-shell"))) { script = argv[1]; try { - auto lines = tokenizeString<Strings>(readFile(script), "\n"); + Strings lines = absl::StrSplit(readFile(script), absl::ByChar('\n')); if (std::regex_search(lines.front(), std::regex("^#!"))) { lines.pop_front(); inShebang = true; @@ -444,7 +445,8 @@ static void _main(int argc, char** argv) { env["NIX_STORE"] = store->storeDir; env["NIX_BUILD_CORES"] = std::to_string(settings.buildCores); - auto passAsFile = tokenizeString<StringSet>(get(drv.env, "passAsFile", "")); + StringSet passAsFile = absl::StrSplit(get(drv.env, "passAsFile", ""), + absl::ByAnyChar(" \t\n\r")); bool keepTmp = false; int fileNr = 0; |