From 826dc56d3a941447d02fad48a47441f2329af0bf Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 27 Oct 2022 14:51:15 -0700 Subject: [PATCH] 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 --- src/corelib/text/qlocale.cpp | 12 ------------ 1 file changed, 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);