diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-01 00:46:14 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-02 17:27:36 +0200 |
commit | 32a750cfdc8293073def714a808ba2098a859acc (patch) | |
tree | 79a07c1ae3a7951576e6d5bc3714afdb3b65027e /src | |
parent | bdc558c932fdb4b651c85d632bd65b9380e2e42a (diff) |
Optimize Function.apply()
Change-Id: I693413e7be5520e13139594f7654a36ce54a59ce
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index ff59db350d..26587bd91b 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -289,17 +289,29 @@ Value FunctionPrototype::method_apply(SimpleCallContext *ctx) Object *arr = arg.asObject(); + quint32 len; if (!arr) { + len = 0; if (!arg.isNullOrUndefined()) { ctx->throwTypeError(); return Value::undefinedValue(); } + } else { + len = ArrayPrototype::getLength(ctx, arr); } - quint32 len = arr ? arr->get(ctx->engine->id_length).toUInt32() : 0; CALLDATA(len); - for (quint32 i = 0; i < len; ++i) - d.args[i] = arr->getIndexed(i); + + if (len) { + if (arr->protoHasArray() || arr->hasAccessorProperty) { + for (quint32 i = 0; i < len; ++i) + d.args[i] = arr->getIndexed(i); + } else { + for (quint32 i = 0; i < len; ++i) + d.args[i] = arr->arrayData[i].value; + } + } + d.thisObject = thisArg; return o->call(d); } |