QDate: Micro-optimize for fromStringIso benchmark.
By using QStringRef instead of QString, we avoid a data copy. This takes the QDateTime::fromStringIso benchmark from 0.79ms to 0.53ms for me. Change-Id: Ibb36067491ffc275ce3b667cb0e04941aa9457f0 Reviewed-by: Marc Mutz <marc.mutz@kdab.com>bb10
parent
897346604e
commit
5857809cc5
|
|
@ -1296,10 +1296,10 @@ QDate QDate::fromString(const QString& string, Qt::DateFormat format)
|
|||
|| (string.size() > 10 && string.at(10).isDigit())) {
|
||||
return QDate();
|
||||
}
|
||||
const int year = string.mid(0, 4).toInt();
|
||||
const int year = string.midRef(0, 4).toInt();
|
||||
if (year <= 0 || year > 9999)
|
||||
return QDate();
|
||||
return QDate(year, string.mid(5, 2).toInt(), string.mid(8, 2).toInt());
|
||||
return QDate(year, string.midRef(5, 2).toInt(), string.midRef(8, 2).toInt());
|
||||
}
|
||||
}
|
||||
return QDate();
|
||||
|
|
|
|||
Loading…
Reference in New Issue