From 8ff4d0bc18c1d46bc409a482ff3637b13b56121e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Mon, 10 Feb 2025 16:10:33 -0800 Subject: [PATCH] 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 Reviewed-by: Edward Welbourne Reviewed-by: Marc Mutz --- src/corelib/global/qtenvironmentvariables.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qtenvironmentvariables.cpp b/src/corelib/global/qtenvironmentvariables.cpp index ae213aa1e39..ffafbdf4180 100644 --- a/src/corelib/global/qtenvironmentvariables.cpp +++ b/src/corelib/global/qtenvironmentvariables.cpp @@ -10,6 +10,7 @@ #include #include +#include #include QT_BEGIN_NAMESPACE @@ -253,11 +254,10 @@ std::optional 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; } /*!