From: Lars Knoll Date: Wed, 30 Jan 2013 14:43:22 +0000 (+0100) Subject: Inline some code for property lookups X-Git-Tag: upstream/5.2.1~669^2~659^2~336 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7e24a7d61f57b3f961d81daa11b336ed60ee4e2c;p=platform%2Fupstream%2Fqtdeclarative.git Inline some code for property lookups Speeds up fact.2.js and crypto.js by ~5-10% Change-Id: I121b6c3dbbd89060f323a422286adf946d4f924a Reviewed-by: Simon Hausmann --- diff --git a/src/v4/qv4object.cpp b/src/v4/qv4object.cpp index e9e3d78..6f5fb60 100644 --- a/src/v4/qv4object.cpp +++ b/src/v4/qv4object.cpp @@ -276,10 +276,16 @@ Value Object::__get__(ExecutionContext *ctx, String *name, bool *hasProperty) return Value::fromObject(prototype); } - if (PropertyDescriptor *p = __getPropertyDescriptor__(ctx, name)) { - if (hasProperty) - *hasProperty = true; - return getValue(ctx, p); + Object *o = this; + while (o) { + if (o->members) { + if (PropertyDescriptor *p = o->members->find(name)) { + if (hasProperty) + *hasProperty = true; + return getValue(ctx, p); + } + } + o = o->prototype; } if (hasProperty) @@ -289,11 +295,28 @@ Value Object::__get__(ExecutionContext *ctx, String *name, bool *hasProperty) Value Object::__get__(ExecutionContext *ctx, uint index, bool *hasProperty) { - const PropertyDescriptor *p = __getPropertyDescriptor__(ctx, index); - if (p && p->type != PropertyDescriptor::Generic) { + PropertyDescriptor *pd = 0; + Object *o = this; + while (o) { + PropertyDescriptor *p = o->array.at(index); + if (p && p->type != PropertyDescriptor::Generic) { + pd = p; + break; + } + if (o->isStringObject()) { + p = static_cast(o)->getIndex(ctx, index); + if (p) { + pd = p; + break; + } + } + o = o->prototype; + } + + if (pd) { if (hasProperty) *hasProperty = true; - return getValue(ctx, p); + return getValue(ctx, pd); } if (hasProperty)