From ca89437d00aeb8916738a964a62aef3cff7dc5ab Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Fri, 13 Aug 2021 16:00:13 +0200 Subject: [PATCH] Use qEnvironmentVariableIntValue() instead of qgetenv().toInt() The docs tell us that it's faster. Pick-to: 6.2 Change-Id: Ib828ed9a10bbb617670a61e7525cbbe25704815d Reviewed-by: Mitch Curtis --- examples/quick/shared/shared.h | 4 ++-- src/quick/scenegraph/coreapi/qsgrenderer.cpp | 2 +- tests/auto/quickcontrols2/snippets/tst_snippets.cpp | 2 +- .../benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/quick/shared/shared.h b/examples/quick/shared/shared.h index a6a468ddcb..b6c7c4a45b 100644 --- a/examples/quick/shared/shared.h +++ b/examples/quick/shared/shared.h @@ -59,13 +59,13 @@ app.setOrganizationDomain("qt-project.org");\ app.setApplicationName(QFileInfo(app.applicationFilePath()).baseName());\ QQuickView view;\ - if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\ + if (qEnvironmentVariableIntValue("QT_QUICK_CORE_PROFILE")) {\ QSurfaceFormat f = view.format();\ f.setProfile(QSurfaceFormat::CoreProfile);\ f.setVersion(4, 4);\ view.setFormat(f);\ }\ - if (qgetenv("QT_QUICK_MULTISAMPLE").toInt()) {\ + if (qEnvironmentVariableIntValue("QT_QUICK_MULTISAMPLE")) {\ QSurfaceFormat f = view.format();\ f.setSamples(4);\ view.setFormat(f);\ diff --git a/src/quick/scenegraph/coreapi/qsgrenderer.cpp b/src/quick/scenegraph/coreapi/qsgrenderer.cpp index 4b3cd9f2c1..e47126754b 100644 --- a/src/quick/scenegraph/coreapi/qsgrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgrenderer.cpp @@ -55,7 +55,7 @@ int qt_sg_envInt(const char *name, int defaultValue) if (Q_LIKELY(!qEnvironmentVariableIsSet(name))) return defaultValue; bool ok = false; - int value = qgetenv(name).toInt(&ok); + int value = qEnvironmentVariableIntValue(name, &ok); return ok ? value : defaultValue; } diff --git a/tests/auto/quickcontrols2/snippets/tst_snippets.cpp b/tests/auto/quickcontrols2/snippets/tst_snippets.cpp index 17ae6aa614..6be53d274e 100644 --- a/tests/auto/quickcontrols2/snippets/tst_snippets.cpp +++ b/tests/auto/quickcontrols2/snippets/tst_snippets.cpp @@ -79,7 +79,7 @@ void tst_Snippets::initTestCase() QDir screenshotsDir(QDir::current().filePath("screenshots")); - takeScreenshots = qgetenv("SCREENSHOTS").toInt(); + takeScreenshots = qEnvironmentVariableIntValue("SCREENSHOTS"); if (takeScreenshots) QVERIFY(screenshotsDir.exists() || QDir::current().mkpath("screenshots")); diff --git a/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp b/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp index bbcb24ca38..ea2a63dc52 100644 --- a/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp +++ b/tests/benchmarks/quickcontrols2/objectcount/tst_objectcount.cpp @@ -42,7 +42,7 @@ using namespace QQuickVisualTestUtil; -static int qt_verbose = qgetenv("VERBOSE").toInt() != 0; +static int qt_verbose = qEnvironmentVariableIntValue("VERBOSE") != 0; Q_GLOBAL_STATIC(QObjectList, qt_qobjects)