From d3a4fd9bf85ab503a343b548c4d96d12dd48ffc6 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 7 Jan 2014 15:36:28 +0100 Subject: Smaller code cleanup Move the check for isEmpty() into ArrayData::getProperty. Change-Id: I1791ced706afadbb2f45883cb1b3915f40500b71 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4arraydata_p.h | 2 +- src/qml/jsruntime/qv4object.cpp | 35 ++++++++++++----------------------- 2 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 89628cde0e..98968fada2 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -224,7 +224,7 @@ inline Property *ArrayData::getProperty(uint index) const if (!this) return 0; if (type != Sparse) { - if (index >= len) + if (index >= len || data[index].value.isEmpty()) return 0; return data + index; } else { diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 142eae82fd..c155e707e8 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -301,11 +301,9 @@ Property *Object::__getOwnProperty__(uint index, PropertyAttributes *attrs) { Property *p = arrayData->getProperty(index); if (p) { - if (!p->value.isEmpty()) { - if (attrs) - *attrs = arrayData->attributes(index); - return p; - } + if (attrs) + *attrs = arrayData->attributes(index); + return p; } if (isStringObject()) { if (attrs) @@ -348,11 +346,9 @@ Property *Object::__getPropertyDescriptor__(uint index, PropertyAttributes *attr while (o) { Property *p = o->arrayData->getProperty(index); if (p) { - if (!p->value.isEmpty()) { - if (attrs) - *attrs = o->arrayData->attributes(index); - return p; - } + if (attrs) + *attrs = o->arrayData->attributes(index); + return p; } if (o->isStringObject()) { Property *p = static_cast(o)->getIndex(index); @@ -639,11 +635,9 @@ ReturnedValue Object::internalGetIndexed(uint index, bool *hasProperty) while (o) { Property *p = o->arrayData->getProperty(index); if (p) { - if (!p->value.isEmpty()) { - pd = p; - attrs = o->arrayData->attributes(index); - break; - } + pd = p; + attrs = o->arrayData->attributes(index); + break; } if (o->isStringObject()) { pd = static_cast(o)->getIndex(index); @@ -760,14 +754,11 @@ void Object::internalPutIndexed(uint index, const ValueRef value) if (internalClass->engine->hasException) return; - Property *pd = 0; PropertyAttributes attrs; - Property *p = arrayData->getProperty(index); - if (p && !p->value.isEmpty()) { - pd = p; + Property *pd = arrayData->getProperty(index); + if (pd) attrs = arrayData->attributes(index); - } if (!pd && isStringObject()) { pd = static_cast(this)->getIndex(index); @@ -954,9 +945,7 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert // Clause 1 { - Property *p = arrayData->getProperty(index); - if (p && !p->value.isEmpty()) - current = p; + current = arrayData->getProperty(index); if (!current && isStringObject()) current = static_cast(this)->getIndex(index); } -- cgit v1.2.3