diff options
author | João Abecasis <joao.abecasis@nokia.com> | 2012-01-12 15:39:17 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-23 17:40:18 +0100 |
commit | 3249aab539b37a98d75329598bd6838082a8158e (patch) | |
tree | f70fce858cc08c4a82338d32a78069f07eea8a2b /src/corelib/tools/qbytearray.h | |
parent | cc568ec342161edee01ecae74ac11bb4c2da46b7 (diff) |
Don't use RefCount int operators
, as those are going away.
The comment in QString/QByteArray::squeeze about shared_null was updated as it
also affects other static data, such as that generated by QStringLiteral and
QByteArrayLiteral.
Change-Id: I26a757d29db62b1e3566a1f7c8d4030918ed8a89
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qbytearray.h')
-rw-r--r-- | src/corelib/tools/qbytearray.h | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h index 2409ff1232..bf75ef6ead 100644 --- a/src/corelib/tools/qbytearray.h +++ b/src/corelib/tools/qbytearray.h @@ -429,9 +429,9 @@ inline const char *QByteArray::data() const inline const char *QByteArray::constData() const { return d->data(); } inline void QByteArray::detach() -{ if (d->ref != 1 || d->offset) realloc(d->size); } +{ if (d->ref.isShared() || d->offset) realloc(d->size); } inline bool QByteArray::isDetached() const -{ return d->ref == 1; } +{ return !d->ref.isShared(); } inline QByteArray::QByteArray(const QByteArray &a) : d(a.d) { d->ref.ref(); } @@ -440,7 +440,7 @@ inline int QByteArray::capacity() const inline void QByteArray::reserve(int asize) { - if (d->ref != 1 || asize > int(d->alloc)) + if (d->ref.isShared() || asize > int(d->alloc)) realloc(asize); if (!d->capacityReserved) { @@ -451,11 +451,12 @@ inline void QByteArray::reserve(int asize) inline void QByteArray::squeeze() { - if (d->ref > 1 || d->size < int(d->alloc)) + if (d->ref.isShared() || d->size < int(d->alloc)) realloc(d->size); if (d->capacityReserved) { - // cannot set unconditionally, since d could be the shared_null/shared_empty (which is const) + // cannot set unconditionally, since d could be shared_null or + // otherwise static. d->capacityReserved = false; } } |