From e9778e6026a68ce3d32bbe841e4b569d55963e97 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Fri, 20 Sep 2024 10:55:20 +0200 Subject: [PATCH] QDateTimeParser: drop an invalid and largely pointless "optimization" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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ø (cherry picked from commit 070ab9e85208c467d2f59f7fdfc7afe627dc37e1) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit c7c64e7d0a5260913e2afe61ef306520a19cf609) Reviewed-by: Allan Sandfeld Jensen --- src/corelib/time/qdatetimeparser.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index 0d0da82ae0a..1802a02eac4 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -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; } }