aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-08-27 13:39:10 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2025-09-02 12:01:28 +0000
commit5c69b1e0836208e420b023d1919d2ec067a373aa (patch)
tree834c0590665fc6d89afda61d5b8bd8fab94e9b5b
parente223cfbdaf9e24618ee3df28efdacc55dddad375 (diff)
QtQml: Inline Sequence::containerPutIndex into its only user
We don't want to expose it from Sequence's interface. Pick-to: 6.8 Task-number: QTBUG-129972 Task-number: QTBUG-139025 Change-Id: I12453fed0143e5e75dfc749b87b197ec328085f7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> (cherry picked from commit 308305c86ad655c1194faee99f45277d22591c79) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit 4db6fc486e2af23c455bc2e9bc5a176f1fd9f325)
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h2
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp83
-rw-r--r--src/qml/jsruntime/qv4sequenceobject_p.h1
3 files changed, 40 insertions, 46 deletions
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index 70f8d23e09..ce52e1f509 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -303,7 +303,7 @@ inline ReturnedValue coerceListType(
ScopedValue v(scope);
for (qsizetype i = 0; i < length; ++i) {
v = array->get(i);
- sequence->containerPutIndexed(i, v);
+ sequence->put(PropertyKey::fromArrayIndex(i), v);
}
return sequence->asReturnedValue();
}
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index c6c3d7d5c7..ffeb760a00 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -286,45 +286,6 @@ static void removeLastInline(Heap::Sequence *p, qsizetype num)
}
}
-bool Sequence::containerPutIndexed(qsizetype index, const Value &value)
-{
- Heap::Sequence *p = d();
- if (p->internalClass->engine->hasException)
- return false;
-
- if (p->isReadOnly()) {
- engine()->throwTypeError(QLatin1String("Cannot insert into a readonly container"));
- return false;
- }
-
- if (p->isReference() && !p->loadReference())
- return false;
-
- const qsizetype count = sizeInline(p);
- const QMetaType valueType = p->valueMetaType();
- const QVariant element = ExecutionEngine::toVariant(value, valueType, false);
-
- if (index < 0)
- return false;
-
- if (index == count) {
- appendInline(p, element);
- } else if (index < count) {
- replaceInline(p, index, element);
- } else {
- /* according to ECMA262r3 we need to insert */
- /* the value at the given index, increasing length to index+1. */
- appendInline(
- p, index - count,
- valueType == QMetaType::fromType<QVariant>() ? QVariant() : QVariant(valueType));
- appendInline(p, element);
- }
-
- if (p->object())
- p->storeReference();
- return true;
-}
-
bool Sequence::containerDeleteIndexedProperty(qsizetype index)
{
Heap::Sequence *p = d();
@@ -413,15 +374,49 @@ qint64 Sequence::virtualGetLength(const Managed *m)
bool Sequence::virtualPut(Managed *that, PropertyKey id, const Value &value, Value *receiver)
{
- if (id.isArrayIndex()) {
- const uint index = id.asArrayIndex();
- if (qIsAtMostSizetypeLimit(index))
- return static_cast<Sequence *>(that)->containerPutIndexed(qsizetype(index), value);
+ if (!id.isArrayIndex())
+ return ReferenceObject::virtualPut(that, id, value, receiver);
+ const uint arrayIndex = id.asArrayIndex();
+ if (!qIsAtMostSizetypeLimit(arrayIndex)) {
generateWarning(that->engine(), QLatin1String("Index out of range during indexed set"));
return false;
}
- return Object::virtualPut(that, id, value, receiver);
+
+ Heap::Sequence *p = static_cast<Sequence *>(that)->d();
+ if (p->internalClass->engine->hasException)
+ return false;
+
+ if (p->isReadOnly()) {
+ p->internalClass->engine->throwTypeError(
+ QLatin1String("Cannot insert into a readonly container"));
+ return false;
+ }
+
+ if (p->isReference() && !p->loadReference())
+ return false;
+
+ const qsizetype index = arrayIndex;
+ const qsizetype count = sizeInline(p);
+ const QMetaType valueType = p->valueMetaType();
+ const QVariant element = ExecutionEngine::toVariant(value, valueType, false);
+
+ if (index == count) {
+ appendInline(p, element);
+ } else if (index < count) {
+ replaceInline(p, index, element);
+ } else {
+ /* according to ECMA262r3 we need to insert */
+ /* the value at the given index, increasing length to index+1. */
+ appendInline(
+ p, index - count,
+ valueType == QMetaType::fromType<QVariant>() ? QVariant() : QVariant(valueType));
+ appendInline(p, element);
+ }
+
+ if (p->object())
+ p->storeReference();
+ return true;
}
bool Sequence::virtualDeleteProperty(Managed *that, PropertyKey id)
diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h
index c6b1641bc1..c7d809659b 100644
--- a/src/qml/jsruntime/qv4sequenceobject_p.h
+++ b/src/qml/jsruntime/qv4sequenceobject_p.h
@@ -124,7 +124,6 @@ public:
static QV4::OwnPropertyKeyIterator *virtualOwnPropertyKeys(const Object *m, Value *target);
static int virtualMetacall(Object *object, QMetaObject::Call call, int index, void **a);
- bool containerPutIndexed(qsizetype index, const QV4::Value &value);
bool containerDeleteIndexedProperty(qsizetype index);
bool containerIsEqualTo(Managed *other);
};