From 070ab9e85208c467d2f59f7fdfc7afe627dc37e1 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. Pick-to: 6.8 6.7 6.5 Change-Id: I1ba443df9340fa63b8765c25004b51467ca5244d Reviewed-by: Tor Arne Vestbø --- 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 7d7e120da09..3f0ca8d9eef 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1619,16 +1619,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; } }