diff options
author | Lars Knoll <[email protected]> | 2014-01-08 13:08:41 +0100 |
---|---|---|
committer | The Qt Project <[email protected]> | 2014-01-20 21:13:48 +0100 |
commit | a7431e41128bd3aa272223746a5bb57597a87de3 (patch) | |
tree | e5308d5fed3474badba313179f2f1891df300bac /src/qml/jsruntime | |
parent | 50d6e51c73a37858699b90d64657cec5e0b53610 (diff) |
Remove Property * return value from ObjectIterator
The added side effect is that the QJSValueIterator is now
somewhat faster.
Change-Id: I01ba9f2a72a34224f5691130df69a91ab75b72e6
Reviewed-by: Simon Hausmann <[email protected]>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator.cpp | 33 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4objectproto.cpp | 7 |
3 files changed, 25 insertions, 17 deletions
diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index f7a5cd7531..64ab671abf 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -82,12 +82,15 @@ ObjectIterator::ObjectIterator(Scope &scope, const ObjectRef o, uint flags) } } -Property *ObjectIterator::next(StringRef name, uint *index, PropertyAttributes *attrs) +void ObjectIterator::next(StringRef name, uint *index, Property *pd, PropertyAttributes *attrs) { name = (String *)0; *index = UINT_MAX; - if (!object) - return 0; + + if (!object) { + *attrs = PropertyAttributes(); + return; + } Property *p = 0; while (1) { @@ -107,7 +110,8 @@ Property *ObjectIterator::next(StringRef name, uint *index, PropertyAttributes * if (pp != p) continue; } - return p; + *pd = *p; + return; } if (flags & WithProtoChain) @@ -118,7 +122,7 @@ Property *ObjectIterator::next(StringRef name, uint *index, PropertyAttributes * arrayIndex = 0; memberIndex = 0; } - return 0; + *attrs = PropertyAttributes(); } ReturnedValue ObjectIterator::nextPropertyName(ValueRef value) @@ -127,14 +131,15 @@ ReturnedValue ObjectIterator::nextPropertyName(ValueRef value) return Encode::null(); PropertyAttributes attrs; + Property p; uint index; Scope scope(object->engine()); ScopedString name(scope); - Property *p = next(name, &index, &attrs); - if (!p) + next(name, &index, &p, &attrs); + if (attrs.isEmpty()) return Encode::null(); - value = object->getValue(p, attrs); + value = object->getValue(&p, attrs); if (!!name) return name->asReturnedValue(); @@ -148,14 +153,15 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString(ValueRef value) return Encode::null(); PropertyAttributes attrs; + Property p; uint index; Scope scope(object->engine()); ScopedString name(scope); - Property *p = next(name, &index, &attrs); - if (!p) + next(name, &index, &p, &attrs); + if (attrs.isEmpty()) return Encode::null(); - value = object->getValue(p, attrs); + value = object->getValue(&p, attrs); if (!!name) return name->asReturnedValue(); @@ -169,11 +175,12 @@ ReturnedValue ObjectIterator::nextPropertyNameAsString() return Encode::null(); PropertyAttributes attrs; + Property p; uint index; Scope scope(object->engine()); ScopedString name(scope); - Property *p = next(name, &index, &attrs); - if (!p) + next(name, &index, &p, &attrs); + if (attrs.isEmpty()) return Encode::null(); if (!!name) diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index 33228cefaa..142895a41a 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -78,7 +78,7 @@ struct Q_QML_EXPORT ObjectIterator ObjectIterator(SafeObject *scratch1, SafeObject *scratch2, const ObjectRef o, uint flags); ObjectIterator(Scope &scope, const ObjectRef o, uint flags); - Property *next(StringRef name, uint *index, PropertyAttributes *attributes = 0); + void next(StringRef name, uint *index, Property *pd, PropertyAttributes *attributes = 0); ReturnedValue nextPropertyName(ValueRef value); ReturnedValue nextPropertyNameAsString(ValueRef value); ReturnedValue nextPropertyNameAsString(); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 9474442a70..806da833ea 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -239,12 +239,13 @@ ReturnedValue ObjectPrototype::method_defineProperties(CallContext *ctx) while (1) { uint index; PropertyAttributes attrs; - Property *pd = it.next(name, &index, &attrs); - if (!pd) + Property pd; + it.next(name, &index, &pd, &attrs); + if (attrs.isEmpty()) break; Property n; PropertyAttributes nattrs; - val = o->getValue(pd, attrs); + val = o->getValue(&pd, attrs); toPropertyDescriptor(ctx, val, &n, &nattrs); if (scope.engine->hasException) return Encode::undefined(); |