fix: cppcheck (21 troballes)

This commit is contained in:
2026-05-16 13:52:31 +02:00
parent a48fe51f73
commit bf7be3a7f1
13 changed files with 96 additions and 117 deletions
+2 -12
View File
@@ -365,12 +365,7 @@ namespace Menu {
// body = (N-1) * ITEM_SPACING + charH — així BOTTOM_PAD és el buit real
// sota el text del darrer ítem, no un buit extra per sobre d'un "slot" buit.
static auto boxHeight(const Page& page) -> int {
int n = 0;
for (const auto& it : page.items) {
if (isVisible(it)) {
++n;
}
}
const int n = static_cast<int>(std::count_if(page.items.begin(), page.items.end(), [](const auto& it) { return isVisible(it); }));
int body = (n == 0) ? 8 : ((n - 1) * ITEM_SPACING) + 8;
int header = HEADER_H + (page.subtitle.empty() ? 0 : SUBTITLE_H);
return header + body + BOTTOM_PAD;
@@ -557,12 +552,7 @@ namespace Menu {
items_y += SUBTITLE_H;
}
// Compta visibles — si cap, dibuixa placeholder (caixa totalment col·lapsada però oberta)
int visible_count = 0;
for (const auto& it : page.items) {
if (isVisible(it)) {
++visible_count;
}
}
const int visible_count = static_cast<int>(std::count_if(page.items.begin(), page.items.end(), [](const auto& it) { return isVisible(it); }));
if (visible_count == 0) {
const char* empty_text = Locale::get("menu.values.empty");
int ew = font_->width(empty_text);