diff options
author | ZYSzys <17367077526@163.com> | 2019-02-25 15:49:38 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2019-03-04 04:34:29 +0300 |
commit | c3386e6cc3c432a417442eb6fa0a06ee7f554ee2 (patch) | |
tree | 16a6bcb7f9a3ff7e3fde5b7c26de82d3b0dd7f0c /src/node_options-inl.h | |
parent | 3826d692cc60cf8a7ea6dc48b425fd75dcc697df (diff) |
src: reduce to simple `const char*` in OptionsParser
> A lot of the `std::string` usage here could be reduced
to simple `const char*`s if it's reasonable to expect the values to be
known at compile-time.
So this commit uses `const char*` to replace most of `std::string` in
`OptionsParser`.
PR-URL: https://github.com/nodejs/node/pull/26297
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Beth Griggs <Bethany.Griggs@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'src/node_options-inl.h')
-rw-r--r-- | src/node_options-inl.h | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/node_options-inl.h b/src/node_options-inl.h index 001bdecbb67..9c8d24e29e9 100644 --- a/src/node_options-inl.h +++ b/src/node_options-inl.h @@ -28,8 +28,8 @@ EnvironmentOptions* PerIsolateOptions::get_per_env_options() { namespace options_parser { template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, bool Options::* field, OptionEnvvarSettings env_setting) { options_.emplace(name, @@ -40,8 +40,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, uint64_t Options::* field, OptionEnvvarSettings env_setting) { options_.emplace( @@ -53,8 +53,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, int64_t Options::* field, OptionEnvvarSettings env_setting) { options_.emplace( @@ -66,8 +66,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, std::string Options::* field, OptionEnvvarSettings env_setting) { options_.emplace( @@ -80,8 +80,8 @@ void OptionsParser<Options>::AddOption(const std::string& name, template <typename Options> void OptionsParser<Options>::AddOption( - const std::string& name, - const std::string& help_text, + const char* name, + const char* help_text, std::vector<std::string> Options::* field, OptionEnvvarSettings env_setting) { options_.emplace(name, OptionInfo { @@ -93,8 +93,8 @@ void OptionsParser<Options>::AddOption( } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, HostPort Options::* field, OptionEnvvarSettings env_setting) { options_.emplace( @@ -106,16 +106,16 @@ void OptionsParser<Options>::AddOption(const std::string& name, } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, NoOp no_op_tag, OptionEnvvarSettings env_setting) { options_.emplace(name, OptionInfo{kNoOp, nullptr, env_setting, help_text}); } template <typename Options> -void OptionsParser<Options>::AddOption(const std::string& name, - const std::string& help_text, +void OptionsParser<Options>::AddOption(const char* name, + const char* help_text, V8Option v8_option_tag, OptionEnvvarSettings env_setting) { options_.emplace(name, @@ -123,27 +123,27 @@ void OptionsParser<Options>::AddOption(const std::string& name, } template <typename Options> -void OptionsParser<Options>::AddAlias(const std::string& from, - const std::string& to) { +void OptionsParser<Options>::AddAlias(const char* from, + const char* to) { aliases_[from] = { to }; } template <typename Options> -void OptionsParser<Options>::AddAlias(const std::string& from, +void OptionsParser<Options>::AddAlias(const char* from, const std::vector<std::string>& to) { aliases_[from] = to; } template <typename Options> void OptionsParser<Options>::AddAlias( - const std::string& from, + const char* from, const std::initializer_list<std::string>& to) { AddAlias(from, std::vector<std::string>(to)); } template <typename Options> -void OptionsParser<Options>::Implies(const std::string& from, - const std::string& to) { +void OptionsParser<Options>::Implies(const char* from, + const char* to) { auto it = options_.find(to); CHECK_NE(it, options_.end()); CHECK_EQ(it->second.type, kBoolean); @@ -153,8 +153,8 @@ void OptionsParser<Options>::Implies(const std::string& from, } template <typename Options> -void OptionsParser<Options>::ImpliesNot(const std::string& from, - const std::string& to) { +void OptionsParser<Options>::ImpliesNot(const char* from, + const char* to) { auto it = options_.find(to); CHECK_NE(it, options_.end()); CHECK_EQ(it->second.type, kBoolean); |