From 0ec2c4720c47282109b618370bf8397bb1d13a56 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Thu, 31 May 2018 14:06:22 +0200 Subject: Simplify storeElement runtime API We can do the isStrict() check and throwTypeError() call in the runtime function instead of doing it twice on the two call sites. Change-Id: I70df3d7fe4333921a85c11b1573e234f7da2f47d Reviewed-by: Lars Knoll --- src/qml/jsruntime/qv4runtime.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/qml/jsruntime/qv4runtime.cpp') diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 48b5657c7f..bcedfa06b5 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -696,7 +696,7 @@ static Q_NEVER_INLINE bool setElementFallback(ExecutionEngine *engine, const Val return o->put(name, value); } -bool Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) +void Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, const Value &index, const Value &value) { uint idx = 0; if (index.asArrayIndex(idx)) { @@ -707,14 +707,15 @@ bool Runtime::method_storeElement(ExecutionEngine *engine, const Value &object, Heap::SimpleArrayData *s = o->arrayData.cast(); if (idx < s->values.size) { s->setData(engine, idx, value); - return true; + return; } } } } } - return setElementFallback(engine, object, index, value); + if (!setElementFallback(engine, object, index, value) && engine->currentStackFrame->v4Function->isStrict()) + engine->throwTypeError(); } ReturnedValue Runtime::method_getIterator(ExecutionEngine *engine, const Value &in, int iterator) -- cgit v1.2.3