aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jscall_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-07-10 07:58:53 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-07-10 10:56:10 +0200
commitb2cd5c805d153bdccd875884292edb118db87e4e (patch)
treebdec0a5d10bc7cfb5d4930f3a9c1d0be7cbd334b /src/qml/jsruntime/qv4jscall_p.h
parent10985a568db8cfb4140140967f7d247627ec4350 (diff)
QtQml: Optimize string/URL check in coerce()
We only need to check isString() once. This will also help static analyzers recognize that we cannot in fact dereference a nullptr there. Coverity-Id: 415866 Change-Id: I2f8462defbd9ffa7f4e0a8f184b920941a524eea Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4jscall_p.h')
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index 7bb38a5fe9..c11a0be6f3 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -345,9 +345,9 @@ inline ReturnedValue coerce(
: engine->newUrlObject()->asReturnedValue();
}
// Since URL properties are stored as string, we need to support the string conversion here.
- return value.isString()
- ? engine->newUrlObject(QUrl(value.stringValue()->toQString()))->asReturnedValue()
- : engine->newUrlObject()->asReturnedValue();
+ if (const String *string = value.stringValue())
+ return engine->newUrlObject(QUrl(string->toQString()))->asReturnedValue();
+ return engine->newUrlObject()->asReturnedValue();
#if QT_CONFIG(regularexpression)
case QMetaType::QRegularExpression:
if (value.as<RegExpObject>())