diff options
| author | Thiago Macieira <thiago.macieira@intel.com> | 2021-11-27 11:13:47 -0800 |
|---|---|---|
| committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-02-15 17:00:05 -0800 |
| commit | 01fe59a3b7e6f4203a54f0ae2920cfc43ea3b3c7 (patch) | |
| tree | 03ffcd3194f7df753ec58cd163a7b8eba8ebd6f1 /src/corelib/serialization/qjsonobject.cpp | |
| parent | d263147921800e7b6d357d1a48f28f21a8092b84 (diff) | |
QJsonObject::removeAt: stop dividing and multiplying by 2
Change-Id: I89446ea06b5742efb194fffd16bb7d17182c6a2a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
| -rw-r--r-- | src/corelib/serialization/qjsonobject.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index ee4ea8ce238..9eeb11cc388 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -310,7 +310,7 @@ static qsizetype indexOf(const QExplicitlySharedDataPointer<QCborContainerPrivat }); *keyExists = (it != end) && o->stringEqualsElement((*it).key(), key); - return (it - begin) * 2; + return it.it - begin.it; } #if QT_STRINGVIEW_LEVEL < 2 @@ -566,7 +566,7 @@ void QJsonObject::removeImpl(T key) if (!keyExists) return; - removeAt(index / 2); + removeAt(index); } #if QT_STRINGVIEW_LEVEL < 2 @@ -619,7 +619,7 @@ QJsonValue QJsonObject::takeImpl(T key) detach(); const QJsonValue v = QJsonPrivate::Value::fromTrustedCbor(o->extractAt(index + 1)); - removeAt(index / 2); + removeAt(index); return v; } @@ -707,7 +707,7 @@ bool QJsonObject::operator!=(const QJsonObject &other) const */ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it) { - removeAt(it.item.index); + removeAt(it.item.index * 2); // index hasn't changed; the container pointer shouldn't have changed // because we shouldn't have detached (detaching happens on obtaining a @@ -1461,8 +1461,8 @@ void QJsonObject::setValueAt(qsizetype i, const QJsonValue &val) void QJsonObject::removeAt(qsizetype index) { detach(); - o->removeAt(2 * index + 1); - o->removeAt(2 * index); + o->removeAt(index + 1); + o->removeAt(index); } size_t qHash(const QJsonObject &object, size_t seed) |
