From 393186b6963834dfefe8bcfe4f2b4ad3af9268c7 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 30 Nov 2021 17:49:52 +0200 Subject: [PATCH] make most detach methods private [ci reset] Signed-off-by: Ivailo Monev --- src/core/tools/qbitarray.cpp | 5 ----- src/core/tools/qbitarray.h | 1 - src/core/tools/qbytearray.h | 2 +- src/core/tools/qcontiguouscache.h | 3 +-- src/core/tools/qhash.h | 3 +-- src/core/tools/qlinkedlist.h | 4 +--- src/core/tools/qlist.h | 4 +--- src/core/tools/qmap.h | 1 - src/core/tools/qset.h | 2 -- src/core/tools/qset.qdoc | 9 --------- src/core/tools/qstring.h | 2 +- src/core/tools/qvector.h | 4 ++-- src/network/kernel/qauthenticator.h | 10 ++++++++-- tests/auto/qhash/tst_qhash.cpp | 3 --- tests/auto/qset/tst_qset.cpp | 14 -------------- tests/benchmarks/core/tools/qstring/tst_bench_qstring.cpp | 2 +- 16 files changed, 17 insertions(+), 52 deletions(-) diff --git a/src/core/tools/qbitarray.cpp b/src/core/tools/qbitarray.cpp index 98321b8cd..f372fc482 100644 --- a/src/core/tools/qbitarray.cpp +++ b/src/core/tools/qbitarray.cpp @@ -228,11 +228,6 @@ void QBitArray::fill(bool value, int begin, int end) setBit(begin++, value); } -/*! \fn void QBitArray::detach() - - \internal -*/ - /*! \fn void QBitArray::clear() Clears the contents of the bit array and makes it empty. diff --git a/src/core/tools/qbitarray.h b/src/core/tools/qbitarray.h index d8b662c21..6eb8ff9f5 100644 --- a/src/core/tools/qbitarray.h +++ b/src/core/tools/qbitarray.h @@ -59,7 +59,6 @@ public: void resize(int size); - inline void detach() { d.detach(); } inline void clear() { d.clear(); } bool testBit(int i) const; diff --git a/src/core/tools/qbytearray.h b/src/core/tools/qbytearray.h index 22177e07d..7eaa46f19 100644 --- a/src/core/tools/qbytearray.h +++ b/src/core/tools/qbytearray.h @@ -120,7 +120,6 @@ public: char *data(); const char *data() const; inline const char *constData() const; - inline void detach(); void clear(); char at(int i) const; @@ -296,6 +295,7 @@ private: static void freeData(Data *); void reallocData(int alloc); QByteArray nulTerminated() const; + inline void detach(); friend class QByteRef; friend class QString; diff --git a/src/core/tools/qcontiguouscache.h b/src/core/tools/qcontiguouscache.h index a55bc98bb..64067a562 100644 --- a/src/core/tools/qcontiguouscache.h +++ b/src/core/tools/qcontiguouscache.h @@ -75,8 +75,6 @@ public: inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(p); } - inline void detach() { if (d->ref != 1) detach_helper(); } - QContiguousCache &operator=(const QContiguousCache &other); #ifdef Q_COMPILER_RVALUE_REFS inline QContiguousCache &operator=(QContiguousCache &&other) @@ -128,6 +126,7 @@ public: void dump() const { p->dump(); } #endif private: + inline void detach() { if (d->ref != 1) detach_helper(); } void detach_helper(); QContiguousCacheData *allocate(int aalloc); diff --git a/src/core/tools/qhash.h b/src/core/tools/qhash.h index 625782b67..aa4270cfe 100644 --- a/src/core/tools/qhash.h +++ b/src/core/tools/qhash.h @@ -188,8 +188,6 @@ public: void reserve(int size); inline void squeeze() { reserve(1); } - inline void detach() { if (d->ref != 1) detach_helper(); } - void clear(); int remove(const Key &key); @@ -368,6 +366,7 @@ public: #endif private: + inline void detach() { if (d->ref != 1) detach_helper(); } void detach_helper(); void freeData(QHashData *d); Node **findNode(const Key &key, uint *hp = nullptr) const; diff --git a/src/core/tools/qlinkedlist.h b/src/core/tools/qlinkedlist.h index 970ca26c4..b527da276 100644 --- a/src/core/tools/qlinkedlist.h +++ b/src/core/tools/qlinkedlist.h @@ -69,9 +69,6 @@ public: inline bool operator!=(const QLinkedList &l) const { return !(*this == l); } inline int size() const { return d->size; } - inline void detach() - { if (d->ref != 1) detach_helper(); } - inline bool isEmpty() const { return d->size == 0; } void clear(); @@ -206,6 +203,7 @@ public: inline QLinkedList &operator<<(const QLinkedList &l) { *this += l; return *this; } private: + inline void detach() { if (d->ref != 1) detach_helper(); } void detach_helper(); void freeData(QLinkedListData*); }; diff --git a/src/core/tools/qlist.h b/src/core/tools/qlist.h index 39d58d41b..281f2ad26 100644 --- a/src/core/tools/qlist.h +++ b/src/core/tools/qlist.h @@ -100,9 +100,6 @@ public: inline bool operator!=(const QList &l) const { return !(*this == l); } inline int size() const { return p.size(); } - - inline void detach() { if (d->ref != 1) detach_helper(d->alloc); } - inline bool isEmpty() const { return p.isEmpty(); } void clear(); @@ -288,6 +285,7 @@ public: { std::list tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } private: + inline void detach() { if (d->ref != 1) detach_helper(d->alloc); } void detach_helper(int alloc); void node_construct(Node *n, const T &t); diff --git a/src/core/tools/qmap.h b/src/core/tools/qmap.h index 614605c9f..3bbc2dfb4 100644 --- a/src/core/tools/qmap.h +++ b/src/core/tools/qmap.h @@ -159,7 +159,6 @@ public: inline bool operator!=(const QMap &other) const { return !(*this == other); } inline int size() const { return d->size; } - inline bool isEmpty() const { return d->size == 0; } inline void detach() { if (d->ref != 1) detach_helper(); } diff --git a/src/core/tools/qset.h b/src/core/tools/qset.h index 41aa693aa..cab7a688b 100644 --- a/src/core/tools/qset.h +++ b/src/core/tools/qset.h @@ -59,8 +59,6 @@ public: inline void squeeze() { q_hash.squeeze(); } - inline void detach() { q_hash.detach(); } - inline void clear() { q_hash.clear(); } inline bool remove(const T &value) { return q_hash.remove(value) != 0; } diff --git a/src/core/tools/qset.qdoc b/src/core/tools/qset.qdoc index ce3ea03e7..ae12d385d 100644 --- a/src/core/tools/qset.qdoc +++ b/src/core/tools/qset.qdoc @@ -216,15 +216,6 @@ */ /*! - \fn void QSet::detach() - - \internal - - Detaches this set from any other sets with which it may share - data. -*/ - -/*! \fn void QSet::clear() Removes all elements from the set. diff --git a/src/core/tools/qstring.h b/src/core/tools/qstring.h index 42c26ab79..3059c8333 100644 --- a/src/core/tools/qstring.h +++ b/src/core/tools/qstring.h @@ -80,7 +80,6 @@ public: inline const QChar *data() const; inline const QChar *constData() const; - inline void detach(); void clear(); inline const QChar at(int i) const; @@ -472,6 +471,7 @@ private: static void freeData(Data *); void reallocData(int alloc); void expand(int i); + inline void detach(); QString multiArg(int numArgs, const QString **args) const; static int compare_helper(const QChar *data1, int length1, const QChar *data2, int length2, diff --git a/src/core/tools/qvector.h b/src/core/tools/qvector.h index c1de3a49a..bd1307f9e 100644 --- a/src/core/tools/qvector.h +++ b/src/core/tools/qvector.h @@ -91,8 +91,6 @@ public: void reserve(int size); inline void squeeze() { reallocData(d->size, d->size); d->capacity = false; } - inline void detach() { if (d->ref != 1) detach_helper(); } - inline T *data() { detach(); return p->array; } inline const T *data() const { return p->array; } inline const T *constData() const { return p->array; } @@ -252,7 +250,9 @@ public: { QVector tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; } inline std::vector toStdVector() const { std::vector tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; } + private: + inline void detach() { if (d->ref != 1) detach_helper(); } void detach_helper(); QVectorData *mallocData(int alloc); void reallocData(int size, int alloc); diff --git a/src/network/kernel/qauthenticator.h b/src/network/kernel/qauthenticator.h index 10206c6cd..1874fbe77 100644 --- a/src/network/kernel/qauthenticator.h +++ b/src/network/kernel/qauthenticator.h @@ -57,10 +57,16 @@ public: void setOption(const QString &opt, const QVariant &value); bool isNull() const; - void detach(); private: - friend class QAuthenticatorPrivate; + void detach(); + QAuthenticatorPrivate *d; + + friend class QAuthenticatorPrivate; + friend class QHttpPrivate; + friend class QHttpNetworkConnectionPrivate; + friend class QHttpSocketEngine; + friend class QHttpNetworkConnectionChannel; }; QT_END_NAMESPACE diff --git a/tests/auto/qhash/tst_qhash.cpp b/tests/auto/qhash/tst_qhash.cpp index 0b46b3dbc..5a5ac9c7b 100644 --- a/tests/auto/qhash/tst_qhash.cpp +++ b/tests/auto/qhash/tst_qhash.cpp @@ -299,7 +299,6 @@ void tst_QHash::insert1() } { Hash hash2 = hash; - hash2.detach(); hash2.remove(1); QVERIFY(hash2.size() == 1); hash2.remove(1); @@ -311,8 +310,6 @@ void tst_QHash::insert1() QVERIFY(hash.size() == 2); } - hash.detach(); - { Hash::iterator it1 = hash.find(1); QVERIFY(it1 != hash.end()); diff --git a/tests/auto/qset/tst_qset.cpp b/tests/auto/qset/tst_qset.cpp index e8749acff..9855e1870 100644 --- a/tests/auto/qset/tst_qset.cpp +++ b/tests/auto/qset/tst_qset.cpp @@ -51,7 +51,6 @@ private slots: void capacity(); void reserve(); void squeeze(); - void detach(); void clear(); void remove(); void contains(); @@ -250,19 +249,6 @@ void tst_QSet::squeeze() QVERIFY(set.capacity() < 100); } -void tst_QSet::detach() -{ - QSet set; - set.detach(); - - set.insert(1); - set.insert(2); - set.detach(); - - QSet copy = set; - set.detach(); -} - void tst_QSet::clear() { QSet set1, set2; diff --git a/tests/benchmarks/core/tools/qstring/tst_bench_qstring.cpp b/tests/benchmarks/core/tools/qstring/tst_bench_qstring.cpp index 241d9a43e..3b794c5ab 100644 --- a/tests/benchmarks/core/tools/qstring/tst_bench_qstring.cpp +++ b/tests/benchmarks/core/tools/qstring/tst_bench_qstring.cpp @@ -150,7 +150,7 @@ void tst_QString::fromLatin1() const QByteArray copy1 = latin1, copy2 = latin1, copy3 = latin1; copy1.chop(1); - copy2.detach(); + copy2.chop(1); copy3 += latin1; // longer length copy2.clear(); -- 2.11.0