diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/compat/removed_api.cpp | 7 | ||||
-rw-r--r-- | src/corelib/text/qbytearraylist.cpp | 6 | ||||
-rw-r--r-- | src/corelib/text/qbytearraylist.h | 10 |
3 files changed, 16 insertions, 7 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp index b2e758d2ca..8d5bfb44a7 100644 --- a/src/corelib/compat/removed_api.cpp +++ b/src/corelib/compat/removed_api.cpp @@ -89,6 +89,13 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes) return fromRfc4122(qToByteArrayViewIgnoringNull(bytes)); } +#include "qbytearraylist.h" + +QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char *sep, int seplen) +{ + return QByteArrayList_join(that, {sep, seplen}); +} + // #include <qotherheader.h> // // implement removed functions from qotherheader.h diff --git a/src/corelib/text/qbytearraylist.cpp b/src/corelib/text/qbytearraylist.cpp index 44a0f6be95..cd77cd905a 100644 --- a/src/corelib/text/qbytearraylist.cpp +++ b/src/corelib/text/qbytearraylist.cpp @@ -144,15 +144,15 @@ static qsizetype QByteArrayList_joinedSize(const QByteArrayList *that, qsizetype return totalLength; } -QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char *sep, int seplen) +QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, QByteArrayView sep) { QByteArray res; - if (const qsizetype joinedSize = QByteArrayList_joinedSize(that, seplen)) + if (const qsizetype joinedSize = QByteArrayList_joinedSize(that, sep.size())) res.reserve(joinedSize); // don't call reserve(0) - it allocates one byte for the NUL const qsizetype size = that->size(); for (qsizetype i = 0; i < size; ++i) { if (i) - res.append(sep, seplen); + res.append(sep); res += that->at(i); } return res; diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h index 83e43e817d..890cbcef2d 100644 --- a/src/corelib/text/qbytearraylist.h +++ b/src/corelib/text/qbytearraylist.h @@ -58,7 +58,10 @@ typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator; #ifndef Q_CLANG_QDOC namespace QtPrivate { +#if QT_REMOVED_SINCE(6, 3) QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength); +#endif + QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, QByteArrayView separator); } #endif @@ -78,17 +81,16 @@ public: using QListSpecialMethodsBase<QByteArray>::contains; inline QByteArray join() const - { return QtPrivate::QByteArrayList_join(self(), nullptr, 0); } + { return join(QByteArrayView{}); } inline QByteArray join(QByteArrayView sep) const // ### Qt 7: merge with the () overload { - Q_ASSERT(sep.size() <= (std::numeric_limits<int>::max)()); - return QtPrivate::QByteArrayList_join(self(), sep.data(), sep.size()); + return QtPrivate::QByteArrayList_join(self(), sep); } Q_WEAK_OVERLOAD inline QByteArray join(const QByteArray &sep) const { return join(QByteArrayView{sep}); } inline QByteArray join(char sep) const - { return QtPrivate::QByteArrayList_join(self(), &sep, 1); } + { return join({&sep, 1}); } }; QT_END_NAMESPACE |