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. Change-Id: I07ec23f3cb174fb197c3fffd17220b846a026b55 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> (cherry picked from commit 826dc56d3a941447d02fad48a47441f2329af0bf) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d056a3234c
commit
9c3434c4e7
@ -4116,12 +4116,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);
|
||||
@ -4152,12 +4146,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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user