fix: bucles cap a ranges algorithms (38 troballes)
This commit is contained in:
@@ -1012,9 +1012,9 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
dynamic_providers_["PALETTE"] = []() -> std::vector<std::string> {
|
||||
std::vector<std::string> result = {"NEXT", "PREV", "SORT", "DEFAULT"};
|
||||
if (Screen::get() != nullptr) {
|
||||
for (const auto& name : Screen::get()->getPaletteNames()) {
|
||||
result.push_back(toUpper(name));
|
||||
}
|
||||
const auto NAMES = Screen::get()->getPaletteNames();
|
||||
std::ranges::transform(NAMES, std::back_inserter(result),
|
||||
[](const auto& name) { return toUpper(name); });
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -1023,10 +1023,11 @@ void CommandRegistry::registerHandlers() { // NOLINT(readability-function-cogni
|
||||
dynamic_providers_["SHADER PRESET"] = []() -> std::vector<std::string> {
|
||||
std::vector<std::string> result = {"NEXT", "PREV"};
|
||||
const bool IS_CRTPI = Options::video.shader.current_shader == Rendering::ShaderType::CRTPI;
|
||||
auto upper_name = [](const auto& p) { return toUpper(p.name); };
|
||||
if (IS_CRTPI) {
|
||||
for (const auto& p : Options::crtpi_presets) { result.push_back(toUpper(p.name)); }
|
||||
std::ranges::transform(Options::crtpi_presets, std::back_inserter(result), upper_name);
|
||||
} else {
|
||||
for (const auto& p : Options::postfx_presets) { result.push_back(toUpper(p.name)); }
|
||||
std::ranges::transform(Options::postfx_presets, std::back_inserter(result), upper_name);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
@@ -1119,7 +1120,8 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
|
||||
if (cat_node.contains("scope")) {
|
||||
const auto& scope_node = cat_node["scope"];
|
||||
if (scope_node.is_sequence()) {
|
||||
for (const auto& s : scope_node) { cat_scopes.push_back(s.get_value<std::string>()); }
|
||||
std::ranges::transform(scope_node, std::back_inserter(cat_scopes),
|
||||
[](const auto& s) { return s.template get_value<std::string>(); });
|
||||
} else {
|
||||
cat_scopes.push_back(scope_node.get_value<std::string>());
|
||||
}
|
||||
@@ -1160,9 +1162,8 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
|
||||
for (auto it = completions_node.begin(); it != completions_node.end(); ++it) {
|
||||
auto path = it.key().get_value<std::string>();
|
||||
std::vector<std::string> opts;
|
||||
for (const auto& opt : *it) {
|
||||
opts.push_back(opt.get_value<std::string>());
|
||||
}
|
||||
std::ranges::transform(*it, std::back_inserter(opts),
|
||||
[](const auto& opt) { return opt.template get_value<std::string>(); });
|
||||
def.completions[path] = std::move(opts);
|
||||
}
|
||||
}
|
||||
@@ -1181,9 +1182,8 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
|
||||
for (auto it = extras_completions.begin(); it != extras_completions.end(); ++it) {
|
||||
auto path = it.key().get_value<std::string>();
|
||||
std::vector<std::string> opts;
|
||||
for (const auto& opt : *it) {
|
||||
opts.push_back(opt.get_value<std::string>());
|
||||
}
|
||||
std::ranges::transform(*it, std::back_inserter(opts),
|
||||
[](const auto& opt) { return opt.template get_value<std::string>(); });
|
||||
def.completions[path] = std::move(opts);
|
||||
}
|
||||
}
|
||||
@@ -1236,10 +1236,9 @@ void CommandRegistry::load(const std::string& yaml_path) { // NOLINT(readabilit
|
||||
}
|
||||
|
||||
auto CommandRegistry::findCommand(const std::string& keyword) const -> const CommandDef* {
|
||||
for (const auto& cmd : commands_) {
|
||||
if (cmd.keyword == keyword) { return &cmd; }
|
||||
}
|
||||
return nullptr;
|
||||
auto it = std::ranges::find_if(commands_,
|
||||
[&keyword](const auto& cmd) { return cmd.keyword == keyword; });
|
||||
return (it != commands_.end()) ? &(*it) : nullptr;
|
||||
}
|
||||
|
||||
auto CommandRegistry::execute(const std::string& keyword, const std::vector<std::string>& args) const -> std::string {
|
||||
|
||||
Reference in New Issue
Block a user