Exploit C++17 init-statements in if to simplify a loop
The serialization converter example's text converter's loadFile() can be made tidier by making the conditions within its loop into a chain. Task-number: QTBUG-111228 Change-Id: Ic82355eab7380a0c671b3805ca140958bb1c5af5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io> (cherry picked from commit d631f888042e3f3f5d4d0284c6bad8eb91e2c9a3) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
a1045b2b0f
commit
9478aa74ee
@ -79,21 +79,14 @@ QVariant TextConverter::loadFile(QIODevice *f, Converter *&outputConverter)
|
||||
QString line;
|
||||
while (!in.atEnd()) {
|
||||
in.readLineInto(&line);
|
||||
|
||||
bool ok;
|
||||
qint64 v = line.toLongLong(&ok);
|
||||
if (ok) {
|
||||
|
||||
if (qint64 v = line.toLongLong(&ok); ok)
|
||||
list.append(v);
|
||||
continue;
|
||||
}
|
||||
|
||||
double d = line.toDouble(&ok);
|
||||
if (ok) {
|
||||
else if (double d = line.toDouble(&ok); ok)
|
||||
list.append(d);
|
||||
continue;
|
||||
}
|
||||
|
||||
list.append(line);
|
||||
else
|
||||
list.append(line);
|
||||
}
|
||||
|
||||
return list;
|
||||
|
Loading…
x
Reference in New Issue
Block a user