diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-08-30 14:39:40 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | bdc558c932fdb4b651c85d632bd65b9380e2e42a (patch) | |
tree | 0bdb468025ddba3e5cb44cdd9f4f8d8b1b0dd791 /src/qml/jsruntime/qv4runtime.cpp | |
parent | 2bd74245fadb69922132f7ca2ae98e645f67742b (diff) |
Optimise property lookups on primitive types
This gives a large speedup on code such as "foo".charAt(2), or
(5.).toString().
Change-Id: I8b6c46f2f69a4b00f82048a9368d8e9baf4d89ee
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 37 |
1 files changed, 15 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 4f195670b2..33521efb02 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -808,19 +808,12 @@ void __qmljs_call_property(ExecutionContext *context, Value *result, const Value void __qmljs_call_property_lookup(ExecutionContext *context, Value *result, const Value &thisObject, uint index, Value *args, int argc) { - Lookup *l = context->lookups + index; + Value func; - Object *baseObject; - if (thisObject.isObject()) - baseObject = thisObject.objectValue(); - else if (thisObject.isString()) - baseObject = context->engine->stringClass->prototype; - else - baseObject = __qmljs_convert_to_object(context, thisObject); + Lookup *l = context->lookups + index; + l->getter(l, &func, thisObject); - Value func; - l->getter(l, &func, Value::fromObject(baseObject)); - FunctionObject *o = func.asFunctionObject(); + Object *o = func.asObject(); if (!o) context->throwTypeError(); @@ -869,21 +862,21 @@ void __qmljs_call_value(ExecutionContext *context, Value *result, const Value *t void __qmljs_construct_global_lookup(ExecutionContext *context, Value *result, uint index, Value *args, int argc) { - Lookup *l = context->lookups + index; Value func; + + Lookup *l = context->lookups + index; l->globalGetter(l, context, &func); - if (Object *f = func.asObject()) { - CallData d; - d.args = args; - d.argc = argc; - Value res = f->construct(d); - if (result) - *result = res; - return; - } + Object *f = func.asObject(); + if (!f) + context->throwTypeError(); - context->throwTypeError(); + CallData d; + d.args = args; + d.argc = argc; + Value res = f->construct(d); + if (result) + *result = res; } |