summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2023-02-01 15:56:50 +0100
committerEdward Welbourne <edward.welbourne@qt.io>2023-03-10 15:39:37 +0100
commit6971bfab440cb9b535856ed56c42a004510e7d5e (patch)
tree8e715fea3d9ac7af7a59e2e650be22cffd7929be
parentfa4b7495b741c3e7943860c5ff15212afceda710 (diff)
QPlatformTheme::removeMnemonics(): simplify space removal
Move the unrelated advance over the removed mnemonic to before space removal and dispense with the obfuscating extra variable counting how much space we remove. Change-Id: Ibb8b1aee0d7281ae21bc9c7aa7ee84289b800f5c Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
-rw-r--r--src/gui/kernel/qplatformtheme.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/kernel/qplatformtheme.cpp b/src/gui/kernel/qplatformtheme.cpp
index 1c90e0eb01..1da438d55a 100644
--- a/src/gui/kernel/qplatformtheme.cpp
+++ b/src/gui/kernel/qplatformtheme.cpp
@@ -834,13 +834,12 @@ QString QPlatformTheme::removeMnemonics(const QString &original)
if (l == 0)
break;
} else if (l >= 4 && mnemonicInParentheses(QStringView{original}.sliced(currPos, 4))) {
- // Also strip any leading space before the mnemonic:
- int n = 0;
- while (finalDest > n && returnText.at(finalDest - n - 1).isSpace())
- ++n;
- finalDest -= n;
+ // Advance over the matched mnemonic:
currPos += 4;
l -= 4;
+ // Also strip any leading space before it:
+ while (finalDest > 0 && returnText.at(finalDest - 1).isSpace())
+ --finalDest;
continue;
}
returnText[finalDest] = original.at(currPos);