diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-01-30 15:43:22 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-01-30 17:33:29 +0100 |
commit | 7e24a7d61f57b3f961d81daa11b336ed60ee4e2c (patch) | |
tree | 3e447995fa367c0f4db45a85d1b5d0e21876d9c3 | |
parent | 021a2ff9c94005bfcf7245e330a5d03da4437af9 (diff) |
Inline some code for property lookups
Speeds up fact.2.js and crypto.js by ~5-10%
Change-Id: I121b6c3dbbd89060f323a422286adf946d4f924a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r-- | src/v4/qv4object.cpp | 37 |
1 files changed, 30 insertions, 7 deletions
diff --git a/src/v4/qv4object.cpp b/src/v4/qv4object.cpp index e9e3d783..6f5fb607 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<StringObject *>(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) |