diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2019-06-10 11:08:29 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@kdab.com> | 2019-06-20 20:48:59 +0200 |
commit | 34fe9232dbf6a9fe58ebc4c7680bb67d2f642c40 (patch) | |
tree | d85afa295e882b84aa11c8861d6b85799c2f7e71 /src/corelib/serialization | |
parent | 84e89c1e9e00d4fab576b876cfa80e92b5602982 (diff) |
Port from QAtomic::load() to loadRelaxed()
Semi-automated, just needed ~20 manual fixes:
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} +
$ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} +
It can be easily improved (e.g. for store check that there are no commas
after the opening parens). The most common offender is QLibrary::load,
and some code using std::atomic directly.
Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Diffstat (limited to 'src/corelib/serialization')
-rw-r--r-- | src/corelib/serialization/qcborvalue.cpp | 16 | ||||
-rw-r--r-- | src/corelib/serialization/qjson_p.h | 2 | ||||
-rw-r--r-- | src/corelib/serialization/qjsonarray.cpp | 2 | ||||
-rw-r--r-- | src/corelib/serialization/qjsonobject.cpp | 4 |
4 files changed, 12 insertions, 12 deletions
diff --git a/src/corelib/serialization/qcborvalue.cpp b/src/corelib/serialization/qcborvalue.cpp index b2e0ba6d53..ba616c0a7d 100644 --- a/src/corelib/serialization/qcborvalue.cpp +++ b/src/corelib/serialization/qcborvalue.cpp @@ -849,7 +849,7 @@ QCborContainerPrivate *QCborContainerPrivate::clone(QCborContainerPrivate *d, qs QCborContainerPrivate *QCborContainerPrivate::detach(QCborContainerPrivate *d, qsizetype reserved) { - if (!d || d->ref.load() != 1) + if (!d || d->ref.loadRelaxed() != 1) return clone(d, reserved); return d; } @@ -884,12 +884,12 @@ void QCborContainerPrivate::replaceAt_complex(Element &e, const QCborValue &valu // detect self-assignment if (Q_UNLIKELY(this == value.container)) { - Q_ASSERT(ref.load() >= 2); + Q_ASSERT(ref.loadRelaxed() >= 2); if (disp == MoveContainer) ref.deref(); // not deref() because it can't drop to 0 QCborContainerPrivate *d = QCborContainerPrivate::clone(this); d->elements.detach(); - d->ref.store(1); + d->ref.storeRelaxed(1); e.container = d; } else { e.container = value.container; @@ -1368,7 +1368,7 @@ static Element decodeBasicValueFromCbor(QCborStreamReader &reader) static inline QCborContainerPrivate *createContainerFromCbor(QCborStreamReader &reader) { auto d = new QCborContainerPrivate; - d->ref.store(1); + d->ref.storeRelaxed(1); d->decodeFromCbor(reader); return d; } @@ -1643,7 +1643,7 @@ QCborValue::QCborValue(const QByteArray &ba) : n(0), container(new QCborContainerPrivate), t(ByteArray) { container->appendByteData(ba.constData(), ba.size(), t); - container->ref.store(1); + container->ref.storeRelaxed(1); } /*! @@ -1656,7 +1656,7 @@ QCborValue::QCborValue(const QString &s) : n(0), container(new QCborContainerPrivate), t(String) { container->append(s); - container->ref.store(1); + container->ref.storeRelaxed(1); } /*! @@ -1671,7 +1671,7 @@ QCborValue::QCborValue(QLatin1String s) : n(0), container(new QCborContainerPrivate), t(String) { container->append(s); - container->ref.store(1); + container->ref.storeRelaxed(1); } /*! @@ -1719,7 +1719,7 @@ QCborValue::QCborValue(const QCborMap &m) QCborValue::QCborValue(QCborTag t, const QCborValue &tv) : n(-1), container(new QCborContainerPrivate), t(Tag) { - container->ref.store(1); + container->ref.storeRelaxed(1); container->append(t); container->append(tv); } diff --git a/src/corelib/serialization/qjson_p.h b/src/corelib/serialization/qjson_p.h index 85fb2a1254..9de53d5b74 100644 --- a/src/corelib/serialization/qjson_p.h +++ b/src/corelib/serialization/qjson_p.h @@ -719,7 +719,7 @@ public: Data *clone(Base *b, int reserve = 0) { int size = sizeof(Header) + b->size; - if (b == header->root() && ref.load() == 1 && alloc >= size + reserve) + if (b == header->root() && ref.loadRelaxed() == 1 && alloc >= size + reserve) return this; if (reserve) { diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp index 3a6244f5ac..6b327619ad 100644 --- a/src/corelib/serialization/qjsonarray.cpp +++ b/src/corelib/serialization/qjsonarray.cpp @@ -1226,7 +1226,7 @@ bool QJsonArray::detach2(uint reserve) d->ref.ref(); return true; } - if (reserve == 0 && d->ref.load() == 1) + if (reserve == 0 && d->ref.loadRelaxed() == 1) return true; QJsonPrivate::Data *x = d->clone(a, reserve); diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp index f92bdd0e80..c1a6328b2f 100644 --- a/src/corelib/serialization/qjsonobject.cpp +++ b/src/corelib/serialization/qjsonobject.cpp @@ -646,7 +646,7 @@ bool QJsonObject::operator!=(const QJsonObject &other) const */ QJsonObject::iterator QJsonObject::erase(QJsonObject::iterator it) { - Q_ASSERT(d && d->ref.load() == 1); + Q_ASSERT(d && d->ref.loadRelaxed() == 1); if (it.o != this || it.i < 0 || it.i >= (int)o->length) return iterator(this, o->length); @@ -1231,7 +1231,7 @@ bool QJsonObject::detach2(uint reserve) d->ref.ref(); return true; } - if (reserve == 0 && d->ref.load() == 1) + if (reserve == 0 && d->ref.loadRelaxed() == 1) return true; QJsonPrivate::Data *x = d->clone(o, reserve); |