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. Pick-to: 6.6 6.5 Task-number: QTBUG-111228 Change-Id: Ic82355eab7380a0c671b3805ca140958bb1c5af5 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Øystein Heskestad <oystein.heskestad@qt.io>
This commit is contained in:
parent
54c2383e81
commit
d631f88804
@ -79,20 +79,13 @@ QVariant TextConverter::loadFile(QIODevice *f, Converter *&outputConverter)
|
|||||||
QString line;
|
QString line;
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
in.readLineInto(&line);
|
in.readLineInto(&line);
|
||||||
|
|
||||||
bool ok;
|
bool ok;
|
||||||
qint64 v = line.toLongLong(&ok);
|
|
||||||
if (ok) {
|
if (qint64 v = line.toLongLong(&ok); ok)
|
||||||
list.append(v);
|
list.append(v);
|
||||||
continue;
|
else if (double d = line.toDouble(&ok); ok)
|
||||||
}
|
|
||||||
|
|
||||||
double d = line.toDouble(&ok);
|
|
||||||
if (ok) {
|
|
||||||
list.append(d);
|
list.append(d);
|
||||||
continue;
|
else
|
||||||
}
|
|
||||||
|
|
||||||
list.append(line);
|
list.append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user