From 4e54a3a46bd80e66eb1b4ed89a753a60f2573925 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 11 Sep 2018 22:18:07 +0200 Subject: Small optimization in Function.apply() Change-Id: I78cd0224399865e2b87bbf2771f70009a9374866 Reviewed-by: Simon Hausmann --- src/qml/jsruntime/qv4functionobject.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/qml/jsruntime/qv4functionobject.cpp') diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index ec041ab064..7dd9c90511 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -357,7 +357,7 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons uint len = arr->getLength(); Scope scope(v4); - Value *arguments = scope.alloc(len); + Value *arguments = scope.alloc(len); if (len) { if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast()->fullyCreated()) { QV4::ArgumentsObject *a = arr->cast(); @@ -375,6 +375,8 @@ ReturnedValue FunctionPrototype::method_apply(const QV4::FunctionObject *b, cons for (quint32 i = alen; i < len; ++i) arguments[i] = Primitive::undefinedValue(); } else { + // need to init the arguments array, as the get() calls below can have side effects + memset(arguments, 0, len*sizeof(Value)); for (quint32 i = 0; i < len; ++i) arguments[i] = arr->get(i); } -- cgit v1.2.3