diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-25T14·54+0100 |
commit | bf452cbc2ae2b209ec262ce858deca470d086f24 (patch) | |
tree | 198e98902be569301ecb9a821b0c9512b128f930 /third_party/nix/src/libutil/config.cc | |
parent | b99b368d17f2e806a61f7abb83c6d3a9e4bbdc38 (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/libutil/config.cc')
-rw-r--r-- | third_party/nix/src/libutil/config.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/third_party/nix/src/libutil/config.cc b/third_party/nix/src/libutil/config.cc index bc81ce77ceb5..9e3f6f85c52d 100644 --- a/third_party/nix/src/libutil/config.cc +++ b/third_party/nix/src/libutil/config.cc @@ -1,14 +1,16 @@ -#define GOOGLE_STRIP_LOG 0 #include "config.hh" +#include <string> #include <utility> +#include <vector> #include <absl/strings/numbers.h> +#include <absl/strings/str_split.h> +#include <absl/strings/string_view.h> #include <glog/logging.h> #include "args.hh" #include "json.hh" -// #include <glog/log_severity.h> namespace nix { @@ -99,7 +101,9 @@ void AbstractConfig::applyConfigFile(const Path& path) { line = std::string(line, 0, hash); } - auto tokens = tokenizeString<std::vector<std::string> >(line); + // TODO(tazjin): absl::string_view after path functions are fixed. + std::vector<std::string> tokens = + absl::StrSplit(line, absl::ByAnyChar(" \t\n\r")); if (tokens.empty()) { continue; } @@ -258,7 +262,7 @@ void BaseSetting<bool>::convertToArg(Args& args, const std::string& category) { template <> void BaseSetting<Strings>::set(const std::string& str) { - value = tokenizeString<Strings>(str); + value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r")); } template <> @@ -276,7 +280,7 @@ void BaseSetting<Strings>::toJSON(JSONPlaceholder& out) { template <> void BaseSetting<StringSet>::set(const std::string& str) { - value = tokenizeString<StringSet>(str); + value = absl::StrSplit(str, absl::ByAnyChar(" \t\n\r")); } template <> |