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.
This commit is contained in:
parent
b99b368d17
commit
bf452cbc2a
29 changed files with 146 additions and 145 deletions
6
third_party/nix/src/nix-build/nix-build.cc
vendored
6
third_party/nix/src/nix-build/nix-build.cc
vendored
|
|
@ -6,6 +6,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include <absl/strings/ascii.h>
|
||||
#include <absl/strings/str_split.h>
|
||||
#include <glog/logging.h>
|
||||
|
||||
#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<Strings>(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<StringSet>(get(drv.env, "passAsFile", ""));
|
||||
StringSet passAsFile = absl::StrSplit(get(drv.env, "passAsFile", ""),
|
||||
absl::ByAnyChar(" \t\n\r"));
|
||||
|
||||
bool keepTmp = false;
|
||||
int fileNr = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue