summaryrefslogtreecommitdiffstats
path: root/src/corelib/serialization/qjsonobject.cpp
diff options
context:
space:
mode:
authorSona Kurazyan <sona.kurazyan@qt.io>2020-07-21 15:24:43 +0200
committerSona Kurazyan <sona.kurazyan@qt.io>2020-07-22 09:33:52 +0200
commit1c4ae44f6f15bcb40d329668756d9a9456ab9348 (patch)
treeb3a3148cafe278dcbc7d0b832bdf045344787f4f /src/corelib/serialization/qjsonobject.cpp
parent76d9d869072d22995fa2cc6cb5fec17c42230dc4 (diff)
Clean-up some Qt 5 leftovers from JSON serialization classes
Change-Id: I2ddf6901d627677395b39bec34c2c47d27e88d0b Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qjsonobject.cpp')
-rw-r--r--src/corelib/serialization/qjsonobject.cpp48
1 files changed, 6 insertions, 42 deletions
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index 1c7fb7885fe..6befa9d2eba 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -141,23 +141,6 @@ QJsonObject::QJsonObject(QCborContainerPrivate *object)
}
/*!
- This method replaces part of the QJsonObject(std::initializer_list<QPair<QString, QJsonValue>> args) body.
- The constructor needs to be inline, but we do not want to leak implementation details
- of this class.
- \note this method is called for an uninitialized object
- \internal
- */
-
-void QJsonObject::initialize()
-{
- // Because we're being called with uninitialized state, we can't do:
- // o = nullptr;
- // QExplicitlyDataSharedPointer::operator= will read the current value
- void *ptr = &o;
- memset(ptr, 0, sizeof(o));
-}
-
-/*!
Destroys the object.
*/
QJsonObject::~QJsonObject() = default;
@@ -452,7 +435,7 @@ QJsonValueRef QJsonObject::atImpl(T key)
bool keyExists = false;
int index = indexOf(o, key, &keyExists);
if (!keyExists) {
- detach2(o->elements.length() / 2 + 1);
+ detach(o->elements.length() / 2 + 1);
o->insertAt(index, key);
o->insertAt(index + 1, QCborValue::fromJsonValue(QJsonValue()));
}
@@ -520,7 +503,7 @@ template <typename T>
QJsonObject::iterator QJsonObject::insertAt(int pos, T key, const QJsonValue &value, bool keyExists)
{
if (o)
- detach2(o->elements.length() / 2 + (keyExists ? 0 : 1));
+ detach(o->elements.length() / 2 + (keyExists ? 0 : 1));
else
o = new QCborContainerPrivate;
@@ -770,7 +753,7 @@ QJsonObject::iterator QJsonObject::findImpl(T key)
int index = o ? indexOf(o, key, &keyExists) : 0;
if (!keyExists)
return end();
- detach2();
+ detach();
return {this, index / 2};
}
@@ -1419,14 +1402,7 @@ QJsonObject::const_iterator QJsonObject::constFindImpl(T key) const
/*!
\internal
*/
-void QJsonObject::detach(uint reserve)
-{
- Q_UNUSED(reserve);
- Q_ASSERT(!reserve);
- detach2(reserve);
-}
-
-bool QJsonObject::detach2(uint reserve)
+bool QJsonObject::detach(uint reserve)
{
if (!o)
return true;
@@ -1437,18 +1413,6 @@ bool QJsonObject::detach2(uint reserve)
/*!
\internal
*/
-void QJsonObject::compact()
-{
- if (!o)
- return;
-
- detach2();
- o->compact(o->elements.length());
-}
-
-/*!
- \internal
- */
QString QJsonObject::keyAt(int i) const
{
Q_ASSERT(o && i >= 0 && i * 2 < o->elements.length());
@@ -1471,7 +1435,7 @@ QJsonValue QJsonObject::valueAt(int i) const
void QJsonObject::setValueAt(int i, const QJsonValue &val)
{
Q_ASSERT(o && i >= 0 && 2 * i + 1 < o->elements.length());
- detach2();
+ detach();
if (val.isUndefined()) {
o->removeAt(2 * i + 1);
o->removeAt(2 * i);
@@ -1485,7 +1449,7 @@ void QJsonObject::setValueAt(int i, const QJsonValue &val)
*/
void QJsonObject::removeAt(int index)
{
- detach2();
+ detach();
o->removeAt(2 * index + 1);
o->removeAt(2 * index);
}