From bf452cbc2ae2b209ec262ce858deca470d086f24 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 25 May 2020 15:54:14 +0100 Subject: refactor(3p/nix): Replace tokenizeStrings with absl::StrSplit 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. --- third_party/nix/src/nix-build/nix-build.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'third_party/nix/src/nix-build') 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 #include +#include #include #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(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(get(drv.env, "passAsFile", "")); + StringSet passAsFile = absl::StrSplit(get(drv.env, "passAsFile", ""), + absl::ByAnyChar(" \t\n\r")); bool keepTmp = false; int fileNr = 0; -- cgit 1.4.1