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,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