1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-16 17:02:37 +01:00

Codechange: Use Utf8View to const-iterate over strings, if no particular error handling is needed.

This commit is contained in:
frosch
2025-04-02 16:16:14 +02:00
committed by frosch
parent 22ab0244d8
commit f06bfc0dad
5 changed files with 45 additions and 50 deletions

View File

@@ -38,6 +38,7 @@
#include "newgrf_engine.h"
#include "core/backup_type.hpp"
#include "gfx_layout.h"
#include "core/utf8.hpp"
#include <stack>
#include <charconv>
@@ -2261,13 +2262,9 @@ bool MissingGlyphSearcher::FindMissingGlyphs()
this->Reset();
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
auto src = text->cbegin();
FontSize size = this->DefaultSize();
FontCache *fc = FontCache::Get(size);
while (src != text->cend()) {
char32_t c = Utf8Consume(src);
for (char32_t c : Utf8View(*text)) {
if (c >= SCC_FIRST_FONT && c <= SCC_LAST_FONT) {
size = (FontSize)(c - SCC_FIRST_FONT);
fc = FontCache::Get(size);