diff options
author | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-09 15:50:55 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@theqtcompany.com> | 2015-04-16 17:14:09 +0000 |
commit | d22db9e458828d403110fa0b9de1ca0c831d7e96 (patch) | |
tree | ab696dd88d47ec47febe4278ebad83ad43c5015d /src/qml/jsruntime/qv4functionobject.cpp | |
parent | 63877c930e8efa119ac16798ed546cdba68f818b (diff) |
Speed up script binding initialization
Don't spend any time repeatedly building the same internal class for the simple
binding functions. We can do that once at engine construction time.
Change-Id: I3777b5bd15ad4a8aaf78ae13bee27e8d8cadc2ee
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index f7433e6365..7006a8892d 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -459,21 +459,27 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) DEFINE_OBJECT_VTABLE(SimpleScriptFunction); Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, Function *function, bool createProto) - : Heap::FunctionObject(scope, function, createProto) + : Heap::FunctionObject(function->compilationUnit->engine->simpleScriptFunctionClass, function->compilationUnit->engine->functionPrototype.asObject()) { + this->scope = scope->d(); + this->function = function; function->compilationUnit->addref(); Q_ASSERT(function); Q_ASSERT(function->code); - // global function - if (!scope) - return; - Scope s(scope); ScopedFunctionObject f(s, this); - f->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(f->formalParameterCount())); + if (createProto) { + ScopedString name(s, function->name()); + f->init(name, createProto); + f->defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(f->formalParameterCount())); + } else { + f->ensureMemberIndex(s.engine, Index_Length); + memberData->data[Index_Name] = function->name(); + memberData->data[Index_Length] = Primitive::fromInt32(f->formalParameterCount()); + } if (scope->d()->strictMode) { ScopedProperty pd(s); |