aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/memory
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-09-16 12:08:06 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-09-20 10:03:56 +0200
commit17bd07cbc5b6cf54716e991765ab3088a710d7b3 (patch)
tree64f0840f9a4da790c37f9a78992a39cfba19c1ae /src/qml/memory
parenta2db40e6c070017960b9f815c66cab354e3466dc (diff)
QML: Optimize QObject method calls
So far, for each method call we had to allocate a new QObjectMethod as we didn't have any lookup to cache the methods. Introduce a new lookup for that and use it for all QObject methods. Since QObjectMethod contains a pointer to the concrete QObject the method was retrieved from, some more care has to be taken: If we are going to call the method right away, we don't need the object since we always have a thisObject and any further retrieval of the same method will result in a call again. This enables us to cache the method for any instance of the same class. When storing the method elsewhere, though, we need to hold on to the object since you can defer the call or connect a handler to a signal or similar. For such operations we do need the object. We can still optimize a bit by re-using the method cache we build the first time around. Fixes: QTBUG-95628 Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/memory')
-rw-r--r--src/qml/memory/qv4heap_p.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index 9b7a0013f8..b4bd3c4cd6 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -208,9 +208,15 @@ struct QV4QPointer {
init(o);
return *this;
}
+
bool isNull() const noexcept
{
- return d == nullptr || qObject == nullptr || d->strongref.loadRelaxed() == 0;
+ return !isValid() || d->strongref.loadRelaxed() == 0;
+ }
+
+ bool isValid() const noexcept
+ {
+ return d != nullptr && qObject != nullptr;
}
private: