summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2025-02-10 16:10:33 -0800
committerThiago Macieira <thiago.macieira@intel.com>2025-02-14 14:02:02 -0800
commit8ff4d0bc18c1d46bc409a482ff3637b13b56121e (patch)
tree77e868281d006a3c35d8d4bb6e46a9f4fdfaf40a
parentfd3c05cd073b11482560d5f0c30bd415ff16ba6f (diff)
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>
-rw-r--r--src/corelib/global/qtenvironmentvariables.cpp8
1 files 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 <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;
}
/*!