From 02b478edb3476c607002a64e2a57b7e202fcd9f6 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 5 Feb 2013 22:13:27 +0100 Subject: [PATCH] Inline some code only used from one place Cleans up the qv4object class definition. Change-Id: Ifca7f89afb3affce5d940b1b4f7dcfe71779012c Reviewed-by: Erik Verbruggen --- src/v4/qv4arrayobject.cpp | 14 +++++++++++++- src/v4/qv4object.cpp | 23 ++++++++++++++++++++++- src/v4/qv4object.h | 38 -------------------------------------- 3 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/v4/qv4arrayobject.cpp b/src/v4/qv4arrayobject.cpp index bec7c22..3079c52 100644 --- a/src/v4/qv4arrayobject.cpp +++ b/src/v4/qv4arrayobject.cpp @@ -322,7 +322,19 @@ Value ArrayPrototype::method_shift(ExecutionContext *ctx) return Value::undefinedValue(); } - Value result = instance->getValueChecked(ctx, instance->front()); + PropertyDescriptor *front = 0; + if (!instance->sparseArray) { + if (instance->arrayDataLen) + front = instance->arrayData; + } else { + SparseArrayNode *n = instance->sparseArray->findNode(0); + if (n) + front = instance->arrayDecriptor(n->value); + } + if (front && front->type == PropertyDescriptor::Generic) + front = 0; + + Value result = instance->getValueChecked(ctx, front); bool protoHasArray = false; Object *p = instance; diff --git a/src/v4/qv4object.cpp b/src/v4/qv4object.cpp index dda340b..d8231b5 100644 --- a/src/v4/qv4object.cpp +++ b/src/v4/qv4object.cpp @@ -551,8 +551,29 @@ bool Object::__delete__(ExecutionContext *ctx, String *name) bool Object::__delete__(ExecutionContext *ctx, uint index) { - if (deleteArrayIndex(index)) + PropertyDescriptor *pd = 0; + if (!sparseArray) { + if (index >= arrayDataLen) + return true; + pd = arrayAt(index); + } else { + SparseArrayNode *n = sparseArray->findNode(index); + if (n) + pd = arrayDecriptor(n->value); + } + if (!pd || pd->type == PropertyDescriptor::Generic) return true; + + if (pd->isConfigurable()) { + pd->type = PropertyDescriptor::Generic; + pd->value = Value::undefinedValue(); + if (sparseArray) { + pd->value.int_32 = arrayFreeList; + arrayFreeList = pd - arrayData; + } + return true; + } + if (ctx->strictMode) __qmljs_throw_type_error(ctx); return false; diff --git a/src/v4/qv4object.h b/src/v4/qv4object.h index c9a4337..7f99668 100644 --- a/src/v4/qv4object.h +++ b/src/v4/qv4object.h @@ -259,30 +259,6 @@ public: fillDescriptor(pd, value); } - bool deleteArrayIndex(uint index) { - PropertyDescriptor *pd = 0; - if (!sparseArray) { - if (index >= arrayDataLen) - return true; - pd = arrayAt(index); - } else { - SparseArrayNode *n = sparseArray->findNode(index); - if (n) - pd = arrayDecriptor(n->value); - } - if (!pd || pd->type == PropertyDescriptor::Generic) - return true; - if (!pd->isConfigurable()) - return false; - pd->type = PropertyDescriptor::Generic; - pd->value = Value::undefinedValue(); - if (sparseArray) { - pd->value.int_32 = arrayFreeList; - arrayFreeList = pd - arrayData; - } - return true; - } - PropertyDescriptor *arrayAt(uint index) const { if (!sparseArray) { if (index >= arrayDataLen) @@ -306,20 +282,6 @@ public: void markArrayObjects() const; - PropertyDescriptor *front() { - PropertyDescriptor *pd = 0; - if (!sparseArray) { - if (arrayDataLen) - pd = arrayData; - } else { - SparseArrayNode *n = sparseArray->findNode(0); - if (n) - pd = arrayDecriptor(n->value); - } - if (pd && pd->type == PropertyDescriptor::Generic) - return 0; - return pd; - } void push_back(Value v) { uint idx = arrayLength(); if (!sparseArray) { -- 2.7.4