aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4runtime.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2018-06-06 14:48:24 +0200
committerLars Knoll <lars.knoll@qt.io>2018-06-21 19:43:24 +0000
commit0562ece42df80cd3ffe3c3fe6b2097202fe65500 (patch)
tree978c370a5a6a8579cabdb2265f4fa534e11ad186 /src/qml/jsruntime/qv4runtime.cpp
parent5454b37f308e78e240ac19947121fae344cda606 (diff)
Unify DeleteMember and DeleteSubscript instructions
The delete operator is rarely used, so it's simpler to unify these into one DeleteProperty instruction. Change-Id: I8c0d4455b35efb03db2ab0010df70030d774a6ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4runtime.cpp')
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index b879e3fc14..4c2477ded2 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -321,36 +321,22 @@ ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId)
return FunctionObject::createScriptFunction(current, clos)->asReturnedValue();
}
-bool Runtime::method_deleteElement(ExecutionEngine *engine, const Value &base, const Value &index)
+bool Runtime::method_deleteProperty(ExecutionEngine *engine, const Value &base, const Value &index)
{
Scope scope(engine);
- ScopedObject o(scope, base);
- if (o) {
- uint n = index.asArrayIndex();
- if (n < UINT_MAX)
- return o->deleteIndexedProperty(n);
- }
+ ScopedObject o(scope, base.toObject(engine));
+ if (scope.engine->hasException)
+ return Encode::undefined();
+ Q_ASSERT(o);
+
+ uint n = index.asArrayIndex();
+ if (n < UINT_MAX)
+ return o->deleteIndexedProperty(n);
ScopedStringOrSymbol name(scope, index.toPropertyKey(engine));
if (engine->hasException)
return false;
- return method_deleteMemberString(engine, base, name);
-}
-
-bool Runtime::method_deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex)
-{
- Scope scope(engine);
- ScopedString name(scope, engine->currentStackFrame->v4Function->compilationUnit->runtimeStrings[nameIndex]);
- return method_deleteMemberString(engine, base, name);
-}
-
-bool Runtime::method_deleteMemberString(ExecutionEngine *engine, const Value &base, StringOrSymbol *name)
-{
- Scope scope(engine);
- ScopedObject obj(scope, base.toObject(engine));
- if (scope.engine->hasException)
- return Encode::undefined();
- return obj->deleteProperty(name);
+ return o->deleteProperty(name);
}
bool Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex)