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.

Pick-to: 6.8 6.7 6.5
Change-Id: I1ba443df9340fa63b8765c25004b51467ca5244d
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
  • Loading branch information
ediosyncratic committed Sep 23, 2024
1 parent 96c0765 commit 070ab9e
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 @@ -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;
}
}

Expand Down

0 comments on commit 070ab9e

Please sign in to comment.