From 6f029d81a0fe3da41aaab3f9629cbbbbad178088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Sun, 14 Apr 2024 22:15:30 +0200 Subject: [PATCH] Code cleanup --- src/map/IMG/lblfile.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/map/IMG/lblfile.cpp b/src/map/IMG/lblfile.cpp index af1de0ab..505b2715 100644 --- a/src/map/IMG/lblfile.cpp +++ b/src/map/IMG/lblfile.cpp @@ -48,12 +48,19 @@ static bool isAllUpperCase(const QString &str) static QString capitalized(const QString &str) { - QString ret(str); - for (int i = 0; i < str.size(); i++) - if (i && !(str.at(i-1).isSpace() || str.at(i-1) == '(')) - ret[i] = str.at(i).toLower(); + QString ret; + + ret.resize(str.size()); + + for (int i = 0; i < str.size(); i++) { + QChar last(str.at(i-1)); + QChar current(str.at(i)); + + if (i && !(last.isSpace() || last == '(')) + ret[i] = current.toLower(); else - ret[i] = str.at(i); + ret[i] = current; + } return ret; }