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-channel/nix-channel.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'third_party/nix/src/nix-channel') diff --git a/third_party/nix/src/nix-channel/nix-channel.cc b/third_party/nix/src/nix-channel/nix-channel.cc index 04a492d80a03..01fc788b9011 100644 --- a/third_party/nix/src/nix-channel/nix-channel.cc +++ b/third_party/nix/src/nix-channel/nix-channel.cc @@ -1,6 +1,7 @@ #include #include +#include #include #include @@ -24,13 +25,15 @@ static void readChannels() { } auto channelsFile = readFile(channelsList); - for (const auto& line : - tokenizeString>(channelsFile, "\n")) { - absl::StripTrailingAsciiWhitespace(line); + std::vector lines = + absl::StrSplit(channelsFile, absl::ByChar('\n')); + + for (auto& line : lines) { + line = absl::StripTrailingAsciiWhitespace(line); if (std::regex_search(line, std::regex("^\\s*\\#"))) { continue; } - auto split = tokenizeString>(line, " "); + std::vector split = absl::StrSplit(line, absl::ByChar(' ')); auto url = std::regex_replace(split[0], std::regex("/*$"), ""); auto name = split.size() > 1 ? split[1] : baseNameOf(url); channels[name] = url; -- cgit 1.4.1