From 89c6271af03b7d2b6b6373f185ee4ff3b67319cb Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Tue, 1 Nov 2022 17:08:45 +0100 Subject: QLocaleData::numberToCLocale(): consolidate two branches The handling of a digit was done in two parts, separating the case for the first digit from the handling of later digits. Nothing in the else/if chain between involved digits, so the latter can move to the front and be combined with the former. Change-Id: I4c93515f36452721bdef472cc2f0af7ceeb00527 Reviewed-by: Thiago Macieira --- src/corelib/text/qlocale.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/corelib/text/qlocale.cpp') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index 83afa4b5b9..a6ba1931cb 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -3948,9 +3948,10 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o } if (!number_options.testFlag(QLocale::RejectGroupSeparator)) { - if (start_of_digits_idx == -1 && out >= '0' && out <= '9') { - start_of_digits_idx = idx; - digitsInGroup++; + if (out >= '0' && out <= '9') { + if (start_of_digits_idx == -1) + start_of_digits_idx = idx; + ++digitsInGroup; } else if (out == ',') { // Don't allow group chars after the decimal point or exponent if (decpt_idx != -1 || exponent_idx != -1) @@ -3979,8 +3980,6 @@ bool QLocaleData::numberToCLocale(QStringView s, QLocale::NumberOptions number_o // stop processing separators last_separator_idx = -1; - } else if (out >= '0' && out <= '9') { - digitsInGroup++; } } else if (out == ',') { return false; -- cgit v1.2.3