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/libstore/builtins/buildenv.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'third_party/nix/src/libstore/builtins/buildenv.cc') diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc index 92cf2f8c1e..db093663bf 100644 --- a/third_party/nix/src/libstore/builtins/buildenv.cc +++ b/third_party/nix/src/libstore/builtins/buildenv.cc @@ -1,6 +1,7 @@ #include #include +#include #include #include #include @@ -134,12 +135,14 @@ static void addPkg(const Path& pkgDir, int priority) { createLinks(pkgDir, out, priority); try { - for (const auto& p : tokenizeString>( + for (auto p : absl::StrSplit( readFile(pkgDir + "/nix-support/propagated-user-env-packages"), - " \n")) - if (!done.count(p)) { - postponed.insert(p); + absl::ByAnyChar(" \n"))) { + auto pkg = std::string(p); + if (!done.count(pkg)) { + postponed.insert(pkg); } + } } catch (SysError& e) { if (e.errNo != ENOENT && e.errNo != ENOTDIR) { throw; @@ -172,7 +175,8 @@ void builtinBuildenv(const BasicDerivation& drv) { /* Convert the stuff we get from the environment back into a * coherent data type. */ Packages pkgs; - auto derivations = tokenizeString(getAttr("derivations")); + Strings derivations = + absl::StrSplit(getAttr("derivations"), absl::ByAnyChar(" \t\n\r")); while (!derivations.empty()) { /* !!! We're trusting the caller to structure derivations env var correctly */ -- cgit 1.4.1