aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-09-11 22:18:07 +0200
committerLars Knoll <lars.knoll@qt.io>2018-09-14 19:21:11 +0000
commit4e54a3a46bd80e66eb1b4ed89a753a60f2573925 (patch)
treedb5a80fe4458b6e95a63929335ba96fa48b29d48 /src/qml
parent92ae20a2140b922ee272edb21ba2a3e87ead5c06 (diff)
Small optimization in Function.apply()
Change-Id: I78cd0224399865e2b87bbf2771f70009a9374866 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp4
1 files changed, 3 insertions, 1 deletions
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<Scope::Uninitialized>(len);
if (len) {
if (ArgumentsObject::isNonStrictArgumentsObject(arr) && !arr->cast<ArgumentsObject>()->fullyCreated()) {
QV4::ArgumentsObject *a = arr->cast<ArgumentsObject>();
@@ -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);
}