diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-10-27 14:51:15 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-03 07:43:58 -0700 |
commit | 826dc56d3a941447d02fad48a47441f2329af0bf (patch) | |
tree | 6e47dbfa35acd23fb1ef18f90a5a2463725618f2 /src/corelib/text/qlocale.cpp | |
parent | 885ae61c6378e06a965f543d2ecbd162c6224347 (diff) |
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>
Diffstat (limited to 'src/corelib/text/qlocale.cpp')
-rw-r--r-- | src/corelib/text/qlocale.cpp | 12 |
1 files changed, 0 insertions, 12 deletions
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index bd41f7ea5b..0ab9a57e0a 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -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); |