aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-01-07 15:36:28 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-09 07:47:13 +0100
commitd3a4fd9bf85ab503a343b548c4d96d12dd48ffc6 (patch)
treef5937219b8e7db4874e5125d8adb870bac161ef9
parent459c9a2a8840995436e610459216957bc7ebd914 (diff)
Smaller code cleanup
Move the check for isEmpty() into ArrayData::getProperty. Change-Id: I1791ced706afadbb2f45883cb1b3915f40500b71 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h2
-rw-r--r--src/qml/jsruntime/qv4object.cpp35
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<const StringObject *>(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<StringObject *>(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<StringObject *>(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<StringObject *>(this)->getIndex(index);
}