Android: iterate over const QJniArray
If/when we introduce mutable QJniArray iterators, then iterating over a mutable array will be significantly more expensive due to the write-back from the reference type. Pick-to: 6.8 Change-Id: I2e8eb357fdb6a9890699f5c61d49b635d303f301 Reviewed-by: Soheil Armin <soheil.armin@qt.io> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
parent
655bed6568
commit
2d4f4220dd
@ -67,9 +67,9 @@ QHash<int, QByteArray> QAndroidItemModelProxy::roleNames() const
|
|||||||
QHash<int, QByteArray> roleNames;
|
QHash<int, QByteArray> roleNames;
|
||||||
HashMap hashMap = jInstance.callMethod<HashMap>("roleNames");
|
HashMap hashMap = jInstance.callMethod<HashMap>("roleNames");
|
||||||
Set set = hashMap.callMethod<Set>("keySet");
|
Set set = hashMap.callMethod<Set>("keySet");
|
||||||
QJniArray<jobject> keyArray = set.callMethod<QJniArray<jobject>>("toArray");
|
const QJniArray keyArray = set.callMethod<jobject[]>("toArray");
|
||||||
|
|
||||||
for (auto key : keyArray) {
|
for (const auto &key : keyArray) {
|
||||||
const QJniObject roleName = hashMap.callMethod<jobject>("get", key);
|
const QJniObject roleName = hashMap.callMethod<jobject>("get", key);
|
||||||
const int intKey = QJniObject(key).callMethod<jint>("intValue");
|
const int intKey = QJniObject(key).callMethod<jint>("intValue");
|
||||||
const QByteArray roleByteArray = String(roleName).toString().toLatin1();
|
const QByteArray roleByteArray = String(roleName).toString().toLatin1();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user