qEnvironmentVariableIntegerValue: bypass middle-men functions

We don't need most of the extra checks that either
QByteArrayView::toInt() or QtPrivate::toSignedInteger() perform. Plus,
QtPrivate::ParsedNumber won't fit a two-register return ABI, while
QSimpleParsedNumber will.

We do need to reintroduce the int check.

Task-number: QTBUG-133654
Change-Id: I693c3e0eb072dab27000fffdd1279750dc83258c
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Thiago Macieira 2025-02-10 16:10:33 -08:00
parent fd3c05cd07
commit 8ff4d0bc18

View File

@ -10,6 +10,7 @@
#include <QtCore/qstring.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/private/qlocale_p.h>
#include <QtCore/private/qlocking_p.h>
QT_BEGIN_NAMESPACE
@ -253,11 +254,10 @@ std::optional<int> qEnvironmentVariableIntegerValue(const char *varName) noexcep
if (!buffer || (size = strlen(buffer)) > MaxDigitsForOctalInt)
return std::nullopt;
#endif
bool ok;
int value = QByteArrayView(buffer, size).toInt(&ok, 0);
if (!ok)
auto r = QLocaleData::bytearrayToLongLong(QByteArrayView(buffer, size), 0);
if (!r.ok() || int(r.result) != r.result)
return std::nullopt;
return value;
return r.result;
}
/*!