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/libexpr/primops/fetchMercurial.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'third_party/nix/src/libexpr/primops/fetchMercurial.cc') diff --git a/third_party/nix/src/libexpr/primops/fetchMercurial.cc b/third_party/nix/src/libexpr/primops/fetchMercurial.cc index b6d4a5e1c8bc..71722faedf11 100644 --- a/third_party/nix/src/libexpr/primops/fetchMercurial.cc +++ b/third_party/nix/src/libexpr/primops/fetchMercurial.cc @@ -3,6 +3,7 @@ #include #include +#include #include #include @@ -48,11 +49,11 @@ HgInfo exportMercurial(ref store, const std::string& uri, hgInfo.branch = absl::StripTrailingAsciiWhitespace( runProgram("hg", true, {"branch", "-R", uri})); - auto files = tokenizeString>( + std::set files = absl::StrSplit( runProgram("hg", true, {"status", "-R", uri, "--clean", "--modified", "--added", "--no-status", "--print0"}), - "\0"s); + absl::ByChar('\0')); PathFilter filter = [&](const Path& p) -> bool { assert(absl::StartsWith(p, uri)); @@ -124,10 +125,11 @@ HgInfo exportMercurial(ref store, const std::string& uri, writeFile(stampFile, ""); } - auto tokens = tokenizeString>( - runProgram("hg", true, - {"log", "-R", cacheDir, "-r", rev, "--template", - "{node} {rev} {branch}"})); + std::vector tokens = + absl::StrSplit(runProgram("hg", true, + {"log", "-R", cacheDir, "-r", rev, "--template", + "{node} {rev} {branch}"}), + absl::ByAnyChar(" \t\n\r")); assert(tokens.size() == 3); HgInfo hgInfo; -- cgit 1.4.1