diff options
author | Erik Verbruggen <erik.verbruggen@theqtcompany.com> | 2016-04-28 11:09:41 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-05-11 12:23:17 +0000 |
commit | 28128f2dc6c5eb63d52658ede840e02b06f9ac2c (patch) | |
tree | fee0d69ebf243f41a2567ea3942bcf8c42a07aeb /tests/auto/qml/qqmlqt/data | |
parent | 39ce4c70e7cfc6b761c2172fe9b048027c220af4 (diff) |
QML: Fill QtObject lazily.
Only iterate over the enumerations/enumerators in the staticQtMetaObject
when a get() is done, and the key/value is not yet in stored in the
underlying Object. The whole cost of the iteration is now moved to get()
and advanceIterator(). The latter will add all items in one swoop, but
iteration over QtObject isn't used much (if at all). The get() will add
all key/value pairs up until it finds the requested key. Checking a
number of applications shows that none of them use all (or the "last")
key, so it will actually save entries (which equals memory) too.
This change reduces the instruction count for QtObject from 2.7M
instructions down to 95k. As this initialization is done from the
QQmlEngine constructor, it also speeds up that initialization.
Task-number: QTBUG-43770
Change-Id: I71331ff76bdacdd4790f7ff0430c4cbc214fe0ab
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
Diffstat (limited to 'tests/auto/qml/qqmlqt/data')
-rw-r--r-- | tests/auto/qml/qqmlqt/data/qtObjectContents.qml | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qml/qqmlqt/data/qtObjectContents.qml b/tests/auto/qml/qqmlqt/data/qtObjectContents.qml new file mode 100644 index 0000000000..c85e7986e9 --- /dev/null +++ b/tests/auto/qml/qqmlqt/data/qtObjectContents.qml @@ -0,0 +1,10 @@ +import QtQuick 2.0 + +QtObject { + property var values: Object() + Component.onCompleted: { + for (var key in Qt) { + values[key] = Qt[key] + } + } +} |