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>
This commit is contained in:
Edward Welbourne 2023-02-01 15:56:50 +01:00
parent fa4b7495b7
commit 6971bfab44

View File

@ -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);