Skip to content

Commit

Permalink
QDateTimeParser: drop an invalid and largely pointless "optimization"
Browse files Browse the repository at this point in the history
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 b6a11a4;
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 070ab9e)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit c7c64e7)
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
  • Loading branch information
ediosyncratic authored and Morten242 committed Oct 1, 2024
1 parent f3fc7b2 commit e9778e6
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/corelib/time/qdatetimeparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit e9778e6

Please sign in to comment.