Permalink
Browse files

src: mark options parsers as const

These do not change their contents after being constructed.

PR-URL: #25065
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information...
addaleax authored and MylesBorins committed Dec 15, 2018
1 parent 7df59f8 commit fd0361bff06eac020b876b91b7d43c2c666a387d
Showing with 12 additions and 12 deletions.
  1. +2 −2 src/node_options-inl.h
  2. +4 −4 src/node_options.cc
  3. +6 −6 src/node_options.h
@@ -214,7 +214,7 @@ auto OptionsParser<Options>::Convert(
template <typename Options>
template <typename ChildOptions>
void OptionsParser<Options>::Insert(
OptionsParser<ChildOptions>* child_options_parser,
const OptionsParser<ChildOptions>* child_options_parser,
ChildOptions* (Options::* get_child)()) {
aliases_.insert(child_options_parser->aliases_.begin(),
child_options_parser->aliases_.end());
@@ -287,7 +287,7 @@ void OptionsParser<Options>::Parse(
std::vector<std::string>* const v8_args,
Options* const options,
OptionEnvvarSettings required_env_settings,
std::vector<std::string>* const errors) {
std::vector<std::string>* const errors) const {
ArgsInfo args(orig_args, exec_args);

// The first entry is the process name. Make sure it ends up in the V8 argv,
@@ -88,7 +88,7 @@ DebugOptionsParser::DebugOptionsParser() {
}

#if HAVE_INSPECTOR
DebugOptionsParser DebugOptionsParser::instance;
const DebugOptionsParser DebugOptionsParser::instance;
#endif // HAVE_INSPECTOR

EnvironmentOptionsParser::EnvironmentOptionsParser() {
@@ -211,7 +211,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
#endif // HAVE_INSPECTOR
}

EnvironmentOptionsParser EnvironmentOptionsParser::instance;
const EnvironmentOptionsParser EnvironmentOptionsParser::instance;

PerIsolateOptionsParser::PerIsolateOptionsParser() {
AddOption("--track-heap-objects",
@@ -234,7 +234,7 @@ PerIsolateOptionsParser::PerIsolateOptionsParser() {
&PerIsolateOptions::get_per_env_options);
}

PerIsolateOptionsParser PerIsolateOptionsParser::instance;
const PerIsolateOptionsParser PerIsolateOptionsParser::instance;

PerProcessOptionsParser::PerProcessOptionsParser() {
AddOption("--title",
@@ -342,7 +342,7 @@ PerProcessOptionsParser::PerProcessOptionsParser() {
&PerProcessOptions::get_per_isolate_options);
}

PerProcessOptionsParser PerProcessOptionsParser::instance;
const PerProcessOptionsParser PerProcessOptionsParser::instance;

inline std::string RemoveBrackets(const std::string& host) {
if (!host.empty() && host.front() == '[' && host.back() == ']')
@@ -281,7 +281,7 @@ class OptionsParser {
// a method that yields the target options type from this parser's options
// type.
template <typename ChildOptions>
void Insert(OptionsParser<ChildOptions>* child_options_parser,
void Insert(const OptionsParser<ChildOptions>* child_options_parser,
ChildOptions* (Options::* get_child)());

// Parse a sequence of options into an options struct, a list of
@@ -306,7 +306,7 @@ class OptionsParser {
std::vector<std::string>* const v8_args,
Options* const options,
OptionEnvvarSettings required_env_settings,
std::vector<std::string>* const errors);
std::vector<std::string>* const errors) const;

private:
// We support the wide variety of different option types by remembering
@@ -397,28 +397,28 @@ class DebugOptionsParser : public OptionsParser<DebugOptions> {
public:
DebugOptionsParser();

static DebugOptionsParser instance;
static const DebugOptionsParser instance;
};

class EnvironmentOptionsParser : public OptionsParser<EnvironmentOptions> {
public:
EnvironmentOptionsParser();

static EnvironmentOptionsParser instance;
static const EnvironmentOptionsParser instance;
};

class PerIsolateOptionsParser : public OptionsParser<PerIsolateOptions> {
public:
PerIsolateOptionsParser();

static PerIsolateOptionsParser instance;
static const PerIsolateOptionsParser instance;
};

class PerProcessOptionsParser : public OptionsParser<PerProcessOptions> {
public:
PerProcessOptionsParser();

static PerProcessOptionsParser instance;
static const PerProcessOptionsParser instance;
};

} // namespace options_parser

0 comments on commit fd0361b

Please sign in to comment.