diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-08-15 01:31:13 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-08-19 05:03:50 +0000 |
commit | 4876ea6a18ccdfd72014582aa5d50ab9f6b6ec9e (patch) | |
tree | 73e9a9ce3ed28b817c77d3d48475c76a7d54c9cf /src/qml/memory | |
parent | 7fccfc4663c362d717383493732849237562f0c7 (diff) |
Fix performance of ListModel::get()
When called, the function would return a full-fledged QObject that maps the
list element addressed. It would contain a _copy_ of all values in the list
item and it would create a new meta-object for each list element.
This function exists for the JavaScript API, and therefore we now return a much
more lightweight object. For compatbility reasons it still has to be a QObject,
but the meta-object of it is created on-demand, i.e. only when accessing
properties from the C++ side or when connecting to the changed signal of a
property. Otherwise the JavaScript wrapper will return the live values from the
model without copying them.
Change-Id: Iabf3ca22192d2aee06ae9d4b4cfb2fcde2a021b1
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Reviewed-by: Spencer Schumann <spencer.schumann@echostar.com>
Diffstat (limited to 'src/qml/memory')
-rw-r--r-- | src/qml/memory/qv4mm.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp index 38b4e1eaf1..b880c9c8d5 100644 --- a/src/qml/memory/qv4mm.cpp +++ b/src/qml/memory/qv4mm.cpp @@ -373,7 +373,7 @@ void MemoryManager::mark() for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) { if (!(*it).isManaged()) continue; - if ((*it).managed()->d()->vtable() != QObjectWrapper::staticVTable()) + if (!(*it).as<QObjectWrapper>()) continue; QObjectWrapper *qobjectWrapper = static_cast<QObjectWrapper*>((*it).managed()); QObject *qobject = qobjectWrapper->object(); @@ -410,10 +410,8 @@ void MemoryManager::sweep(bool lastSweep) continue; // we need to call detroyObject on qobjectwrappers now, so that they can emit the destroyed // signal before we start sweeping the heap - if ((*it).managed()->d()->vtable() == QObjectWrapper::staticVTable()) { - QObjectWrapper *qobjectWrapper = static_cast<QObjectWrapper*>((*it).managed()); + if (QObjectWrapper *qobjectWrapper = (*it).as<QObjectWrapper>()) qobjectWrapper->destroyObject(lastSweep); - } (*it) = Primitive::undefinedValue(); } |