aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4sequenceobject.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2025-08-27 13:39:10 +0200
committerUlf Hermann <ulf.hermann@qt.io>2025-09-01 19:25:20 +0200
commit308305c86ad655c1194faee99f45277d22591c79 (patch)
treee6802beb63ca87722225e3019854afe76c948942 /src/qml/jsruntime/qv4sequenceobject.cpp
parentf3b565a1db51c3368988bdc35cac4bdf1929c3e6 (diff)
QtQml: Inline Sequence::containerPutIndex into its only user
We don't want to expose it from Sequence's interface. Pick-to: 6.10 6.9 6.8 Task-number: QTBUG-129972 Task-number: QTBUG-139025 Change-Id: I12453fed0143e5e75dfc749b87b197ec328085f7 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4sequenceobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp83
1 files changed, 39 insertions, 44 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index 2f267dce74..df19dfa959 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)