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);
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;
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);
protected:
Managed(InternalClass *internal)
: _data(0), vtbl(&static_vtbl), internalClass(internal)
- { inUse = 1; extensible = 1; }
+ { inUse = 1; extensible = 1; hasAccessorProperty = 0; }
public:
void *operator new(size_t size, MemoryManager *mm);
uint type : 8;
mutable uint subtype : 3;
uint bindingKeyFlag : 1;
- uint unused : 12;
+ uint hasAccessorProperty : 1;
+ uint unused : 11;
};
};
uint idx;
internalClass = internalClass->addMember(s, attributes, &idx);
+ if (attributes.isAccessor())
+ hasAccessorProperty = 1;
+
if (idx >= memberDataAlloc) {
memberDataAlloc = qMax((uint)8, 2*memberDataAlloc);
Property *newMemberData = new Property[memberDataAlloc];
cattrs->setWritable(false);
if (!succeeded)
goto reject;
+ if (attrs.isAccessor())
+ hasAccessorProperty = 1;
return true;
}
if (arrayAttributes)
arrayAttributes[current - arrayData] = cattrs;
}
+ if (attrs.isAccessor())
+ hasAccessorProperty = 1;
return true;
reject:
if (ctx->strictMode)
{
Q_ASSERT(isArrayObject());
- bool protoHasArray = false;
- Object *p = other;
- while ((p = p->prototype))
- if (p->arrayDataLen)
- protoHasArray = true;
-
- bool arrayHasGetter = false;
- if (!protoHasArray && other->arrayAttributes) {
- for (uint i = 0; i < other->arrayDataLen; ++i) {
- if (other->arrayAttributes[i].isAccessor()) {
- const Property &pd = other->arrayData[i];
- FunctionObject *getter = pd.getter();
- if (getter) {
- arrayHasGetter = true;
- break;
- }
- }
- }
- }
-
- if (protoHasArray || arrayHasGetter) {
+ if (other->protoHasArray() || other->hasAccessorProperty) {
uint len = other->arrayLength();
Q_ASSERT(len);
Value Object::arrayIndexOf(Value v, uint fromIndex, uint endIndex, ExecutionContext *ctx, Object *o)
{
- bool protoHasArray = false;
- Object *p = o;
- while ((p = p->prototype))
- if (p->arrayDataLen)
- protoHasArray = true;
-
- if (protoHasArray || o->arrayAttributes) {
+ if (o->protoHasArray() || o->arrayAttributes) {
// lets be safe and slow
for (uint i = fromIndex; i < endIndex; ++i) {
bool exists;
void setArrayLengthUnchecked(uint l);
Property *arrayInsert(uint index, PropertyAttributes attributes = Attr_Data) {
+ if (attributes.isAccessor())
+ hasAccessorProperty = 1;
Property *pd;
if (!sparseArray && (index < 0x1000 || index < arrayDataLen + (arrayDataLen >> 2))) {
void arrayReserve(uint n);
void ensureArrayAttributes();
+ inline bool protoHasArray() {
+ Object *p = this;
+
+ while ((p = p->prototype))
+ if (p->arrayDataLen)
+ return true;
+
+ return false;
+ }
+
inline Value get(String *name, bool *hasProperty = 0)
{ return vtbl->get(this, name, hasProperty); }
inline Value getIndexed(uint idx, bool *hasProperty = 0)