diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2025-08-27 13:35:59 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2025-09-01 19:25:20 +0200 |
| commit | f3b565a1db51c3368988bdc35cac4bdf1929c3e6 (patch) | |
| tree | 0c1ee079d97d93255f457cf4f67b89c16055ffe0 /src/qml/jsruntime/qv4sequenceobject.cpp | |
| parent | 28d6d704e7212c91f5aee7cdb61d809a7de85902 (diff) | |
QtQml: Inline Sequence::containerGetIndexed() 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: Ic001925c7fc1ae3be623e2fd7451f99d17899471
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 | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 4cb99999a9..2f267dce74 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -286,22 +286,6 @@ static void removeLastInline(Heap::Sequence *p, qsizetype num) } } -ReturnedValue Sequence::containerGetIndexed(qsizetype index, bool *hasProperty) const -{ - Heap::Sequence *p = d(); - if (p->isReference() && !p->loadReference()) - return Encode::undefined(); - - if (index >= 0 && index < sizeInline(p)) { - if (hasProperty) - *hasProperty = true; - return doGetIndexed(this, index); - } - if (hasProperty) - *hasProperty = false; - return Encode::undefined(); -} - bool Sequence::containerPutIndexed(qsizetype index, const Value &value) { Heap::Sequence *p = d(); @@ -392,16 +376,31 @@ bool Heap::Sequence::storeReference() ReturnedValue Sequence::virtualGet(const Managed *that, PropertyKey id, const Value *receiver, bool *hasProperty) { - if (id.isArrayIndex()) { - const uint index = id.asArrayIndex(); - if (qIsAtMostSizetypeLimit(index)) - return static_cast<const Sequence *>(that)->containerGetIndexed(qsizetype(index), hasProperty); + if (!id.isArrayIndex()) + return ReferenceObject::virtualGet(that, id, receiver, hasProperty); + const uint arrayIndex = id.asArrayIndex(); + if (!qIsAtMostSizetypeLimit(arrayIndex)) { generateWarning(that->engine(), QLatin1String("Index out of range during indexed get")); return false; } - return Object::virtualGet(that, id, receiver, hasProperty); + const Sequence *s = static_cast<const Sequence *>(that); + Heap::Sequence *p = s->d(); + + if (p->isReference() && !p->loadReference()) + return Encode::undefined(); + + const qsizetype index = arrayIndex; + if (index < sizeInline(p)) { + if (hasProperty) + *hasProperty = true; + return doGetIndexed(s, index); + } + + if (hasProperty) + *hasProperty = false; + return Encode::undefined(); } qint64 Sequence::virtualGetLength(const Managed *m) |
