From a7431e41128bd3aa272223746a5bb57597a87de3 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 8 Jan 2014 13:08:41 +0100 Subject: 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 --- src/qml/jsruntime/qv4objectiterator.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'src/qml/jsruntime/qv4objectiterator.cpp') 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) -- cgit v1.2.3