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/qv4objectiterator.cpp | |
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/qv4objectiterator.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4objectiterator.cpp | 33 |
1 files changed, 20 insertions, 13 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) |