aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arrayobject.cpp
diff options
context:
space:
mode:
authorPeter Varga <pvarga@inf.u-szeged.hu>2013-08-15 15:54:15 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-17 12:51:56 +0200
commit221f93d8c76ae5e5e4b6d73b1b597213abbbc5f5 (patch)
tree58d943799116b746c593659a5c5eb6e658ae95a7 /src/qml/jsruntime/qv4arrayobject.cpp
parent900ff8ed90468fc89f4800c793dd3cde3e586d21 (diff)
Factor out protoHasArray and hasAccessorProperty
The Object::protoHasArray() function returns true if any object in the prototype chain contains an array element. The new member hasAccessorProperty of the Managed class is set true if the object has any accessor property. Change-Id: Ic29d303eb058d4faed2a47ed8fab18e376ccba68 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4arrayobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp24
1 files changed, 3 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index ee69be4e31..d7f4babbb2 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -269,13 +269,7 @@ Value ArrayPrototype::method_push(SimpleCallContext *ctx)
return Value::fromDouble(newLen);
}
- bool protoHasArray = false;
- Object *p = instance;
- while ((p = p->prototype))
- if (p->arrayDataLen)
- protoHasArray = true;
-
- if (!protoHasArray && instance->arrayDataLen <= len) {
+ if (!instance->protoHasArray() && instance->arrayDataLen <= len) {
for (uint i = 0; i < ctx->argumentCount; ++i) {
Value v = ctx->argument(i);
@@ -349,13 +343,7 @@ Value ArrayPrototype::method_shift(SimpleCallContext *ctx)
Value result = front ? instance->getValue(front, instance->arrayAttributes ? instance->arrayAttributes[pidx] : Attr_Data) : Value::undefinedValue();
- bool protoHasArray = false;
- Object *p = instance;
- while ((p = p->prototype))
- if (p->arrayDataLen)
- protoHasArray = true;
-
- if (!protoHasArray && instance->arrayDataLen <= len) {
+ if (!instance->protoHasArray() && instance->arrayDataLen <= len) {
if (!instance->sparseArray) {
if (instance->arrayDataLen) {
++instance->arrayOffset;
@@ -502,13 +490,7 @@ Value ArrayPrototype::method_unshift(SimpleCallContext *ctx)
Object *instance = ctx->thisObject.toObject(ctx);
uint len = getLength(ctx, instance);
- bool protoHasArray = false;
- Object *p = instance;
- while ((p = p->prototype))
- if (p->arrayDataLen)
- protoHasArray = true;
-
- if (!protoHasArray && instance->arrayDataLen <= len) {
+ if (!instance->protoHasArray() && instance->arrayDataLen <= len) {
for (int i = ctx->argumentCount - 1; i >= 0; --i) {
Value v = ctx->argument(i);