Add a shortcut in QDateTimeParser::findTimeZone for UTC
In a small example program using HTTPS (on Windows with Schannel) >40% of the time was spent initializing the backend, attempting to find the time zone used in various certificates. By adding an early check to see if the requested time zone is UTC (or an alias ('Z')) we can skip most of the lookup that was required. In the example program this cut away ~200ms of a total of ~550ms. Change-Id: I4d29568653e02b64feebbf329469899eb7be1494 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
6ec3321875
commit
6e89ed5a3c
@ -1657,8 +1657,11 @@ QDateTimeParser::ParsedSection QDateTimeParser::findUtcOffset(QStringView str) c
|
||||
{
|
||||
const bool startsWithUtc = str.startsWith(QLatin1String("UTC"));
|
||||
// Get rid of UTC prefix if it exists
|
||||
if (startsWithUtc)
|
||||
if (startsWithUtc) {
|
||||
str = str.sliced(3);
|
||||
if (str.isEmpty())
|
||||
return ParsedSection(Acceptable, 0, 3);
|
||||
}
|
||||
|
||||
const bool negativeSign = str.startsWith(QLatin1Char('-'));
|
||||
// Must start with a sign:
|
||||
@ -1759,6 +1762,10 @@ QDateTimeParser::ParsedSection
|
||||
QDateTimeParser::findTimeZone(QStringView str, const QDateTime &when,
|
||||
int maxVal, int minVal) const
|
||||
{
|
||||
// Short-cut Zulu suffix when it's all there is (rather than a prefix match):
|
||||
if (str == QLatin1Char('Z'))
|
||||
return ParsedSection(Acceptable, 0, 1);
|
||||
|
||||
ParsedSection section = findUtcOffset(str);
|
||||
if (section.used <= 0) // if nothing used, try time zone parsing
|
||||
section = findTimeZoneName(str, when);
|
||||
|
Loading…
Reference in New Issue
Block a user