Skip to content

Commit 88f047b

Browse files
lemireRafaelGSS
authored andcommitted
src: use ranges library (C++20) to simplify code
PR-URL: #57975 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com>
1 parent 924ebcd commit 88f047b

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/node_options-inl.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33

44
#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
55

6+
#include <algorithm>
67
#include <cstdlib>
8+
#include <ranges>
79
#include "node_options.h"
810
#include "util.h"
911

@@ -393,15 +395,16 @@ void OptionsParser<Options>::Parse(
393395
// Implications for negated options are defined with "--no-".
394396
implied_name.insert(2, "no-");
395397
}
396-
auto implications = implications_.equal_range(implied_name);
397-
for (auto imp = implications.first; imp != implications.second; ++imp) {
398-
if (imp->second.type == kV8Option) {
399-
v8_args->push_back(imp->second.name);
400-
} else {
401-
*imp->second.target_field->template Lookup<bool>(options) =
402-
imp->second.target_value;
403-
}
404-
}
398+
auto [f, l] = implications_.equal_range(implied_name);
399+
std::ranges::for_each(std::ranges::subrange(f, l) | std::views::values,
400+
[&](const auto& value) {
401+
if (value.type == kV8Option) {
402+
v8_args->push_back(value.name);
403+
} else {
404+
*value.target_field->template Lookup<bool>(
405+
options) = value.target_value;
406+
}
407+
});
405408
}
406409

407410
if (it == options_.end()) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy