QDateTimeParser: drop an invalid and largely pointless "optimization"

Now that the maximum and minimum might not be in local time, the day
might not be the same as the local time day. In any case, the "saving"
of checking for being past the end of that day is negligible compared
to all the other wanton costs of the date-time parser.

This is a follow-up to commit b6a11a4ee5319366f14c11c7cf3a4f1dbf33cfd5;
thanks to Tor Arne for reporting the resulting assertion failures.

Fixes: QTBUG-129347
Change-Id: I1ba443df9340fa63b8765c25004b51467ca5244d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
(cherry picked from commit 070ab9e85208c467d2f59f7fdfc7afe627dc37e1)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c7c64e7d0a5260913e2afe61ef306520a19cf609)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
This commit is contained in:
Edward Welbourne 2024-09-20 10:55:20 +02:00 committed by Mårten Nordheim
parent f3fc7b210f
commit e9778e6026

View File

@ -1612,16 +1612,11 @@ QDateTimeParser::parse(const QString &input, int position,
}
}
} else {
if (context == FromString) {
// optimization
Q_ASSERT(maximum.date().toJulianDay() == 5373484);
if (scan.value.date().toJulianDay() > 5373484)
scan.state = Invalid;
} else if (scan.value > maximum) {
if (scan.value > maximum)
scan.state = Invalid;
}
QDTPDEBUG << "not checking intermediate because scanned value is" << scan.value << minimum << maximum;
QDTPDEBUG << "not checking intermediate because scanned value is"
<< scan.value << minimum << maximum;
}
}