refactor: zbylé tři nálezy z review — rozpočet, rename, duplicity

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
tthandClaude Opus 5 committed 2026-09-21 22:37:20 +02:00
1 parent 871f75d246
commit e7fdec8404
5 files changed
+104 -31

No files matched your search

+7 -8
View File
@@ -89,15 +89,14 @@ inline size_t battIconWidth() {
return (sizeof(BATT_ICON_MARKER) - 1) + (lvl > ext ? lvl : ext);
}
// Bytes of app_data left for the name. Mirrors AdvertDataBuilder::encodeTo():
// one byte of flags, plus 4+4 for lat/lon when a position is advertised.
inline size_t advertNameBudget(bool with_loc) {
return MAX_ADVERT_DATA_SIZE - 1 - (with_loc ? 8 : 0);
}
// Does the name still fit with the indicator appended?
inline bool battIconFits(size_t name_len, bool with_loc) {
return name_len + battIconWidth() <= advertNameBudget(with_loc);
//
// `budget` musí přijít z AdvertDataBuilder::nameBudget(), ne z druhého výpočtu
// tady: rozpočet závisí i na FEAT1/FEAT2, a kopie, která o nich nevěděla, by
// tvrdila o 2-4 bajty víc, než je pravda. Pak by UTF-8 clamp uřízl glyf
// vpůli -- přesně to tiché selhání, které tenhle soubor jinde odmítá.
inline bool battIconFits(size_t name_len, size_t budget) {
return name_len + battIconWidth() <= budget;
}
// Copy the glyph for `level` into dest, which must hold