Make zone-name part of date-time parsing a little faster
QDateTimeParser::findTimeZoneName()'s invalidZoneNameCharacter() check was using QLatin1String::contains(QChar), which converts the Latin-1 string to UTF-16 on each call, despite having pre-checked that the QChar is ASCII. So use memchr() instead. Change-Id: I011e2b4ba3be20711fc5005f62e4f9f6a392dd16 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
c36f18b449
commit
7c65935810
@ -1734,8 +1734,8 @@ QDateTimeParser::findTimeZoneName(QStringView str, const QDateTime &when) const
|
||||
// Collect up plausibly-valid characters; let QTimeZone work out what's
|
||||
// truly valid.
|
||||
const auto invalidZoneNameCharacter = [] (const QChar &c) {
|
||||
return c.unicode() >= 127u
|
||||
|| (!c.isLetterOrNumber() && !QLatin1String("+-./:_").contains(c));
|
||||
const auto cu = c.unicode();
|
||||
return cu >= 127u || !(memchr("+-./:_", char(cu), 6) || c.isLetterOrNumber());
|
||||
};
|
||||
int index = std::distance(str.cbegin(),
|
||||
std::find_if(str.cbegin(), str.cend(), invalidZoneNameCharacter));
|
||||
|
Loading…
x
Reference in New Issue
Block a user