diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-08-27 13:45:27 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-09-01 19:25:20 +0200 |
| commit | 8953a873fa279a88a0ac45ad722ac229acf7bd24 (patch) | |
| tree | c290cc47589736b955de98f06fb5bb316cbdf75f /src/qml/jsruntime/qv4sequenceobject.cpp | |
| parent | 308305c86ad655c1194faee99f45277d22591c79 (diff) | |
QtQml: Inline containerDeleteIndexedProperty 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: I35c37ea1da675a83a1a8d3a4af08e4301c8cd60c
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.cpp | 49 |
1 files changed, 24 insertions, 25 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index df19dfa959..eea02926e1 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -286,26 +286,6 @@ static void removeLastInline(Heap::Sequence *p, qsizetype num) } } -bool Sequence::containerDeleteIndexedProperty(qsizetype index) -{ - Heap::Sequence *p = d(); - if (p->isReadOnly()) - return false; - if (p->isReference() && !p->loadReference()) - return false; - if (index < 0 || index >= sizeInline(p)) - return false; - - /* according to ECMA262r3 it should be Undefined, */ - /* but we cannot, so we insert a default-value instead. */ - replaceInline(p, index, QVariant()); - - if (p->object()) - p->storeReference(); - - return true; -} - bool Sequence::containerIsEqualTo(Managed *other) { if (!other) @@ -421,15 +401,34 @@ bool Sequence::virtualPut(Managed *that, PropertyKey id, const Value &value, Val bool Sequence::virtualDeleteProperty(Managed *that, PropertyKey id) { - if (id.isArrayIndex()) { - const uint index = id.asArrayIndex(); - if (qIsAtMostSizetypeLimit(index)) - return static_cast<Sequence *>(that)->containerDeleteIndexedProperty(qsizetype(index)); + if (!id.isArrayIndex()) + return ReferenceObject::virtualDeleteProperty(that, id); + const uint arrayIndex = id.asArrayIndex(); + if (!qIsAtMostSizetypeLimit(arrayIndex)) { generateWarning(that->engine(), QLatin1String("Index out of range during indexed delete")); return false; } - return Object::virtualDeleteProperty(that, id); + + Heap::Sequence *p = static_cast<Sequence *>(that)->d(); + + if (p->isReadOnly()) + return false; + if (p->isReference() && !p->loadReference()) + return false; + + const qsizetype index = arrayIndex; + if (index >= sizeInline(p)) + return false; + + /* according to ECMA262r3 it should be Undefined, */ + /* but we cannot, so we insert a default-value instead. */ + replaceInline(p, index, QVariant()); + + if (p->object()) + p->storeReference(); + + return true; } bool Sequence::virtualIsEqualTo(Managed *that, Managed *other) |
