summaryrefslogtreecommitdiff
path: root/src/node.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2019-01-06 02:48:05 +0100
committerAnna Henningsen <anna@addaleax.net>2019-01-09 00:26:01 +0100
commit8ec3c350f54933d9237c63dd17a9a24472fce591 (patch)
tree26b36685870e5db3214c21c9bd114ea674dae151 /src/node.cc
parent0c8dedd103f78e3f6f9cc907240b9beaabdf12c3 (diff)
downloadandroid-node-v8-8ec3c350f54933d9237c63dd17a9a24472fce591.tar.gz
android-node-v8-8ec3c350f54933d9237c63dd17a9a24472fce591.tar.bz2
android-node-v8-8ec3c350f54933d9237c63dd17a9a24472fce591.zip
src: use generic helper for splitting strings
PR-URL: https://github.com/nodejs/node/pull/25363 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/node.cc')
-rw-r--r--src/node.cc28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/node.cc b/src/node.cc
index 01c9c072da..24b0167b89 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -282,9 +282,12 @@ static struct {
if (per_process::cli_options->trace_event_categories.empty()) {
tracing_file_writer_ = tracing_agent_->DefaultHandle();
} else {
+ std::vector<std::string> categories =
+ SplitString(per_process::cli_options->trace_event_categories, ',');
+
tracing_file_writer_ = tracing_agent_->AddClient(
- ParseCommaSeparatedSet(
- per_process::cli_options->trace_event_categories),
+ std::set<std::string>(std::make_move_iterator(categories.begin()),
+ std::make_move_iterator(categories.end())),
std::unique_ptr<tracing::AsyncTraceWriter>(
new tracing::NodeTraceWriter(
per_process::cli_options->trace_event_file_pattern)),
@@ -1420,23 +1423,10 @@ void Init(std::vector<std::string>* argv,
#if !defined(NODE_WITHOUT_NODE_OPTIONS)
std::string node_options;
if (credentials::SafeGetenv("NODE_OPTIONS", &node_options)) {
- std::vector<std::string> env_argv;
- // [0] is expected to be the program name, fill it in from the real argv.
- env_argv.push_back(argv->at(0));
-
- // Split NODE_OPTIONS at each ' ' character.
- std::string::size_type index = std::string::npos;
- do {
- std::string::size_type prev_index = index;
- index = node_options.find(' ', index + 1);
- if (index - prev_index == 1) continue;
-
- const std::string option = node_options.substr(
- prev_index + 1, index - prev_index - 1);
- if (!option.empty())
- env_argv.emplace_back(std::move(option));
- } while (index != std::string::npos);
-
+ // [0] is expected to be the program name, fill it in from the real argv
+ // and use 'x' as a placeholder while parsing.
+ std::vector<std::string> env_argv = SplitString("x " + node_options, ' ');
+ env_argv[0] = argv->at(0);
ProcessArgv(&env_argv, nullptr, true);
}