QLocale: remove unwise early return in bytearrayTo(Uns)LongLong

Optimize the code for non-empty strings, which are the vast majority of
the conversions. Plus, qstrnto(u)ll operate just fine on empty strings.

This saves 4 instrctions per call on my laptop for any non-empty input,
and up to 4 cycles of execution.

Pick-to: 6.4
Change-Id: I07ec23f3cb174fb197c3fffd17220b846a026b55
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
bb10
Thiago Macieira 2022-10-27 14:51:15 -07:00
parent 885ae61c63
commit 826dc56d3a
1 changed files with 0 additions and 12 deletions

View File

@ -4144,12 +4144,6 @@ qulonglong QLocaleData::stringToUnsLongLong(QStringView str, int base, bool *ok,
qlonglong QLocaleData::bytearrayToLongLong(QByteArrayView num, int base, bool *ok)
{
if (num.isEmpty() || num.at(0) == '\0') {
if (ok != nullptr)
*ok = false;
return 0;
}
bool _ok;
const char *endptr;
const qlonglong l = qstrntoll(num.data(), num.size(), &endptr, base, &_ok);
@ -4180,12 +4174,6 @@ qlonglong QLocaleData::bytearrayToLongLong(QByteArrayView num, int base, bool *o
qulonglong QLocaleData::bytearrayToUnsLongLong(QByteArrayView num, int base, bool *ok)
{
if (num.isEmpty() || num.at(0) == '\0') {
if (ok != nullptr)
*ok = false;
return 0;
}
bool _ok;
const char *endptr;
const qulonglong l = qstrntoull(num.data(), num.size(), &endptr, base, &_ok);