Skip to content

Commit

Permalink
src: mark options parsers as const
Browse files Browse the repository at this point in the history
These do not change their contents after being constructed.

PR-URL: #25065
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Joyee Cheung <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
addaleax authored and MylesBorins committed Dec 26, 2018
1 parent 7df59f8 commit fd0361b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/node_options-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ DebugOptionsParser::DebugOptionsParser() {
}

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

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

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

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

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

PerProcessOptionsParser::PerProcessOptionsParser() {
AddOption("--title",
Expand Down Expand Up @@ -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() == ']')
Expand Down
12 changes: 6 additions & 6 deletions src/node_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fd0361b

Please sign in to comment.