about summary refs log tree commit diff
path: root/third_party/nix/src/nix/run.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T14·54+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T14·54+0100
commitbf452cbc2ae2b209ec262ce858deca470d086f24 (patch)
tree198e98902be569301ecb9a821b0c9512b128f930 /third_party/nix/src/nix/run.cc
parentb99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (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/run.cc')
-rw-r--r--third_party/nix/src/nix/run.cc18
1 files changed, 9 insertions, 9 deletions
diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc
index fa471bd542a1..47103e8db3cd 100644
--- a/third_party/nix/src/nix/run.cc
+++ b/third_party/nix/src/nix/run.cc
@@ -1,3 +1,8 @@
+#include <queue>
+
+#include <absl/strings/str_split.h>
+#include <sys/mount.h>
+
 #include "affinity.hh"
 #include "command.hh"
 #include "common-args.hh"
@@ -8,12 +13,6 @@
 #include "shared.hh"
 #include "store-api.hh"
 
-#if __linux__
-#include <sys/mount.h>
-#endif
-
-#include <queue>
-
 using namespace nix;
 
 std::string chrootHelperName = "__run_in_chroot";
@@ -124,7 +123,7 @@ struct CmdRun : InstallablesCommand {
       todo.push(path);
     }
 
-    auto unixPath = tokenizeString<Strings>(getEnv("PATH"), ":");
+    Strings unixPath = absl::StrSplit(getEnv("PATH"), absl::ByChar(':'));
 
     while (!todo.empty()) {
       Path path = todo.front();
@@ -137,8 +136,9 @@ struct CmdRun : InstallablesCommand {
 
       auto propPath = path + "/nix-support/propagated-user-env-packages";
       if (accessor->stat(propPath).type == FSAccessor::tRegular) {
-        for (auto& p : tokenizeString<Paths>(readFile(propPath))) {
-          todo.push(p);
+        for (auto p :
+             absl::StrSplit(readFile(propPath), absl::ByAnyChar(" \t\n\r"))) {
+          todo.push(std::string(p));
         }
       }
     }