refactor: prefer Sorted variant of MakeFixedFlatSet() (#39537)
perf: prefer Sorted variant of MakeFixedFlatSet()
4660000
says that the sorted version is simpler at compile time because it
can skip MakeFixedFlatSet()'s compile-time dynamic sorting.
This commit is contained in:
parent
8374b9c2ad
commit
213388cd87
3 changed files with 32 additions and 23 deletions
|
@ -54,7 +54,8 @@ namespace {
|
||||||
// See https://nodejs.org/api/cli.html#cli_options
|
// See https://nodejs.org/api/cli.html#cli_options
|
||||||
void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
|
void ExitIfContainsDisallowedFlags(const std::vector<std::string>& argv) {
|
||||||
// Options that are unilaterally disallowed.
|
// Options that are unilaterally disallowed.
|
||||||
static constexpr auto disallowed = base::MakeFixedFlatSet<base::StringPiece>({
|
static constexpr auto disallowed =
|
||||||
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
"--enable-fips",
|
"--enable-fips",
|
||||||
"--force-fips",
|
"--force-fips",
|
||||||
"--openssl-config",
|
"--openssl-config",
|
||||||
|
|
|
@ -45,7 +45,7 @@ electron::UsbChooserContext* GetChooserContext(
|
||||||
// These extensions can claim the smart card USB class and automatically gain
|
// These extensions can claim the smart card USB class and automatically gain
|
||||||
// permissions for devices that have an interface with this class.
|
// permissions for devices that have an interface with this class.
|
||||||
constexpr auto kSmartCardPrivilegedExtensionIds =
|
constexpr auto kSmartCardPrivilegedExtensionIds =
|
||||||
base::MakeFixedFlatSet<base::StringPiece>({
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
// Smart Card Connector Extension and its Beta version, see
|
// Smart Card Connector Extension and its Beta version, see
|
||||||
// crbug.com/1233881.
|
// crbug.com/1233881.
|
||||||
"khpfeaanjngmcnplbdlpegiifgpfgdco",
|
"khpfeaanjngmcnplbdlpegiifgpfgdco",
|
||||||
|
|
|
@ -232,7 +232,7 @@ void ErrorMessageListener(v8::Local<v8::Message> message,
|
||||||
// If node CLI inspect support is disabled, allow no debug options.
|
// If node CLI inspect support is disabled, allow no debug options.
|
||||||
bool IsAllowedOption(base::StringPiece option) {
|
bool IsAllowedOption(base::StringPiece option) {
|
||||||
static constexpr auto debug_options =
|
static constexpr auto debug_options =
|
||||||
base::MakeFixedFlatSet<base::StringPiece>({
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
"--debug",
|
"--debug",
|
||||||
"--debug-brk",
|
"--debug-brk",
|
||||||
"--debug-port",
|
"--debug-port",
|
||||||
|
@ -244,12 +244,13 @@ bool IsAllowedOption(base::StringPiece option) {
|
||||||
});
|
});
|
||||||
|
|
||||||
// This should be aligned with what's possible to set via the process object.
|
// This should be aligned with what's possible to set via the process object.
|
||||||
static constexpr auto options = base::MakeFixedFlatSet<base::StringPiece>({
|
static constexpr auto options =
|
||||||
"--trace-warnings",
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
"--trace-deprecation",
|
|
||||||
"--throw-deprecation",
|
|
||||||
"--no-deprecation",
|
|
||||||
"--dns-result-order",
|
"--dns-result-order",
|
||||||
|
"--no-deprecation",
|
||||||
|
"--throw-deprecation",
|
||||||
|
"--trace-deprecation",
|
||||||
|
"--trace-warnings",
|
||||||
});
|
});
|
||||||
|
|
||||||
if (debug_options.contains(option))
|
if (debug_options.contains(option))
|
||||||
|
@ -262,11 +263,18 @@ bool IsAllowedOption(base::StringPiece option) {
|
||||||
// See https://nodejs.org/api/cli.html#cli_node_options_options
|
// See https://nodejs.org/api/cli.html#cli_node_options_options
|
||||||
void SetNodeOptions(base::Environment* env) {
|
void SetNodeOptions(base::Environment* env) {
|
||||||
// Options that are unilaterally disallowed
|
// Options that are unilaterally disallowed
|
||||||
static constexpr auto disallowed = base::MakeFixedFlatSet<base::StringPiece>(
|
static constexpr auto disallowed =
|
||||||
{"--enable-fips", "--force-fips", "--openssl-config", "--use-bundled-ca",
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
"--use-openssl-ca", "--experimental-policy"});
|
"--enable-fips",
|
||||||
|
"--experimental-policy",
|
||||||
|
"--force-fips",
|
||||||
|
"--openssl-config",
|
||||||
|
"--use-bundled-ca",
|
||||||
|
"--use-openssl-ca",
|
||||||
|
});
|
||||||
|
|
||||||
static constexpr auto pkg_opts = base::MakeFixedFlatSet<base::StringPiece>({
|
static constexpr auto pkg_opts =
|
||||||
|
base::MakeFixedFlatSetSorted<base::StringPiece>({
|
||||||
"--http-parser",
|
"--http-parser",
|
||||||
"--max-http-header-size",
|
"--max-http-header-size",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue