diff options
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4runtime.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 0a098ff7ef..7b1a38ff06 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -349,15 +349,21 @@ QV4::ReturnedValue Runtime::method_instanceof(ExecutionEngine *engine, const Val if (!rhs) return engine->throwTypeError(); + const FunctionObject *f = rhs->as<FunctionObject>(); + // shortcut hasInstance evaluation. In this case we know that we are calling the regular hasInstance() + // method of the FunctionPrototype + if (f && f->d()->prototype() == engine->functionPrototype()->d() && !f->hasHasInstanceProperty()) + return Object::checkedInstanceOf(engine, f, lval); + Scope scope(engine); ScopedValue hasInstance(scope, rhs->get(engine->symbol_hasInstance())); if (hasInstance->isUndefined()) return rhs->instanceOf(lval); - FunctionObject *f = hasInstance->as<FunctionObject>(); - if (!f) + FunctionObject *fHasInstance = hasInstance->as<FunctionObject>(); + if (!fHasInstance) return engine->throwTypeError(); - ScopedValue result(scope, f->call(&rval, &lval, 1)); + ScopedValue result(scope, fHasInstance->call(&rval, &lval, 1)); return Encode(result->toBoolean()); } |