diff options
| author | Lars Knoll <lars.knoll@qt.io> | 2016-12-08 21:01:51 +0100 |
|---|---|---|
| committer | Lars Knoll <lars.knoll@qt.io> | 2016-12-09 08:30:41 +0000 |
| commit | 9f4cfec74517f7ff3f65037ad04abac33e2104ba (patch) | |
| tree | 52fb2f553cb0ee47dafc13d8e594e0cbf3b0fcb3 /src/qml/jsruntime/qv4functionobject.cpp | |
| parent | 260f45d539b3ec1b28f593706ce7c164836f814c (diff) | |
Avoid some copies of Values on the JS stack
Change-Id: I1c7dca6e8d17da9f3d76b68d072370b087840f2b
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject.cpp')
| -rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 02ea763b30..66549ffd3e 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -216,8 +216,7 @@ Heap::FunctionObject *FunctionObject::createQmlFunction(QQmlContextData *qmlCont runtimeFunction->updateInternalClass(engine, signalParameters); } - QV4::ScopedFunctionObject function(valueScope, QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction)); - return function->d(); + return QV4::FunctionObject::createScriptFunction(wrapperContext, runtimeFunction); } @@ -344,11 +343,11 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) { - Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>()); + FunctionObject *o = ctx->thisObject().as<FunctionObject>(); if (!o) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedValue arg(scope, ctx->argument(1)); ScopedObject arr(scope, arg); @@ -387,12 +386,11 @@ ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) ReturnedValue FunctionPrototype::method_call(CallContext *ctx) { - Scope scope(ctx); - - ScopedFunctionObject o(scope, ctx->thisObject().as<FunctionObject>()); + FunctionObject *o = ctx->thisObject().as<FunctionObject>(); if (!o) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0); if (ctx->argc()) { for (int i = 1; i < ctx->argc(); ++i) @@ -406,11 +404,11 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) { - Scope scope(ctx); - ScopedFunctionObject target(scope, ctx->thisObject()); + FunctionObject *target = ctx->thisObject().as<FunctionObject>(); if (!target) return ctx->engine()->throwTypeError(); + Scope scope(ctx); ScopedValue boundThis(scope, ctx->argument(0)); Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)0); if (ctx->argc() > 1) { @@ -601,7 +599,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal QQmlPropertyCapture::registerQmlDependencies(f->function()->compiledFunction, scope); } -Heap::Object *SimpleScriptFunction::protoForConstructor() +Heap::Object *SimpleScriptFunction::protoForConstructor() const { Scope scope(engine()); ScopedObject p(scope, protoProperty()); |
