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
18
third_party/nix/src/libstore/derivations.cc
vendored
18
third_party/nix/src/libstore/derivations.cc
vendored
|
|
@ -1,6 +1,8 @@
|
|||
#include "derivations.hh"
|
||||
|
||||
#include <absl/strings/match.h>
|
||||
#include <absl/strings/str_split.h>
|
||||
#include <absl/strings/string_view.h>
|
||||
|
||||
#include "fs-accessor.hh"
|
||||
#include "globals.hh"
|
||||
|
|
@ -357,13 +359,15 @@ Hash hashDerivationModulo(Store& store, Derivation drv) {
|
|||
return hashString(htSHA256, drv.unparse());
|
||||
}
|
||||
|
||||
DrvPathWithOutputs parseDrvPathWithOutputs(const std::string& s) {
|
||||
size_t n = s.find('!');
|
||||
return n == std::string::npos
|
||||
? DrvPathWithOutputs(s, std::set<std::string>())
|
||||
: DrvPathWithOutputs(std::string(s, 0, n),
|
||||
tokenizeString<std::set<std::string> >(
|
||||
std::string(s, n + 1), ","));
|
||||
// TODO(tazjin): doc comment?
|
||||
DrvPathWithOutputs parseDrvPathWithOutputs(absl::string_view path) {
|
||||
auto pos = path.find('!');
|
||||
if (pos == absl::string_view::npos) {
|
||||
return DrvPathWithOutputs(path, std::set<std::string>());
|
||||
}
|
||||
|
||||
return DrvPathWithOutputs(path.substr(pos + 1),
|
||||
absl::StrSplit(path, absl::ByChar(',')));
|
||||
}
|
||||
|
||||
Path makeDrvPathWithOutputs(const Path& drvPath,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue