From a11be5881a38933d36facfbc4f8baa1becd22546 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Mon, 5 Dec 2016 14:23:09 +0100 Subject: Directly store the referenced QV4::Function pointer in the binding function There's no need to store a pointer to the original function here, we can simplify the code when storing the pointer to the QV4::Function directly. Change-Id: I377aaecf56a0118606713c26cc7da4da001766b1 Reviewed-by: Simon Hausmann --- src/qml/qml/qqmljavascriptexpression.cpp | 4 ---- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 19 +++---------------- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 6 ------ 3 files changed, 3 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index e10b4ef946..6383b631cd 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -462,10 +462,6 @@ void QQmlJavaScriptExpression::setFunctionObject(const QV4::FunctionObject *o) m_qmlScope.set(o->engine(), o->d()->scope); m_v4Function = o->d()->function; - if (o->isBinding()) { - const QV4::QQmlBindingFunction *b = static_cast(o); - m_v4Function = b->d()->originalFunction->function; - } Q_ASSERT(m_v4Function); m_compilationUnit = m_v4Function->compilationUnit; } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index aa2b8a24ec..19dc100f40 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1303,8 +1303,9 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) void Heap::QQmlBindingFunction::init(const QV4::FunctionObject *originalFunction) { - QV4::Heap::FunctionObject::init(originalFunction->scope(), originalFunction->name()); - this->originalFunction = originalFunction->d(); + Scope scope(originalFunction->engine()); + ScopedContext context(scope, originalFunction->scope()); + FunctionObject::init(context, originalFunction->function()); } QQmlSourceLocation QQmlBindingFunction::currentLocation() const @@ -1313,20 +1314,6 @@ QQmlSourceLocation QQmlBindingFunction::currentLocation() const return QQmlSourceLocation(frame.source, frame.line, 0); } -void QQmlBindingFunction::call(const Managed *that, Scope &scope, CallData *callData) -{ - ScopedFunctionObject function(scope, static_cast(that)->d()->originalFunction); - function->call(scope, callData); -} - -void QQmlBindingFunction::markObjects(Heap::Base *that, ExecutionEngine *e) -{ - QQmlBindingFunction::Data *This = static_cast(that); - if (This->originalFunction) - This->originalFunction->mark(e); - QV4::FunctionObject::markObjects(that, e); -} - DEFINE_OBJECT_VTABLE(QQmlBindingFunction); /*! diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index dc2cd04cbe..fe43532647 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -82,7 +82,6 @@ struct ConsoleObject : Object { struct QQmlBindingFunction : FunctionObject { void init(const QV4::FunctionObject *originalFunction); - Pointer originalFunction; }; } @@ -179,13 +178,8 @@ struct Q_QML_PRIVATE_EXPORT GlobalExtensions { struct QQmlBindingFunction : public QV4::FunctionObject { V4_OBJECT2(QQmlBindingFunction, FunctionObject) - V4_NEEDS_DESTROY QQmlSourceLocation currentLocation() const; // from caller stack trace - - static void call(const Managed *that, Scope &scope, CallData *callData); - - static void markObjects(Heap::Base *that, ExecutionEngine *e); }; } -- cgit v1.2.3