summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-01-22 01:03:19 +0100
committerMarc Mutz <marc.mutz@qt.io>2022-01-22 13:08:05 +0100
commit3ec587666f89c996cc0a403775c352954d8b804f (patch)
tree136de574c1e26e4ab150902b5c319269cea10b81 /src/corelib
parent902087a090cfeae36adcb1b9f0948987ad7d2f4c (diff)
QByteArrayList: optimize 32-bit builds of legacy join() helper
On 32-bit machines, qsizetype is int, so we don't actually need to QT_REMOVE_SINCE the QByteArrayList_join() helper, because it didn't change. Thanks to Thiago for showing me the QT_POINTER_SIZE trick in a similar change to QVersionNumber. Pick-to: 6.3 Change-Id: Iae6e315107e42da51fcb4e7325b6d40b9c3fe0bc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/compat/removed_api.cpp4
-rw-r--r--src/corelib/text/qbytearraylist.cpp6
-rw-r--r--src/corelib/text/qbytearraylist.h6
3 files changed, 9 insertions, 7 deletions
diff --git a/src/corelib/compat/removed_api.cpp b/src/corelib/compat/removed_api.cpp
index 5f59cf047a..d27656bf7a 100644
--- a/src/corelib/compat/removed_api.cpp
+++ b/src/corelib/compat/removed_api.cpp
@@ -108,10 +108,12 @@ QUuid QUuid::fromRfc4122(const QByteArray &bytes)
#include "qbytearraylist.h"
+# if QT_POINTER_SIZE != 4
QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char *sep, int seplen)
{
- return QByteArrayList_join(that, {sep, seplen});
+ return QByteArrayList_join(that, sep, qsizetype(seplen));
}
+# endif
#endif // QT_REMOVED_SINCE(6, 3)
diff --git a/src/corelib/text/qbytearraylist.cpp b/src/corelib/text/qbytearraylist.cpp
index e23bdc7bd8..129bcfc835 100644
--- a/src/corelib/text/qbytearraylist.cpp
+++ b/src/corelib/text/qbytearraylist.cpp
@@ -138,15 +138,15 @@ static qsizetype QByteArrayList_joinedSize(const QByteArrayList *that, qsizetype
return totalLength;
}
-QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, QByteArrayView sep)
+QByteArray QtPrivate::QByteArrayList_join(const QByteArrayList *that, const char *sep, qsizetype seplen)
{
QByteArray res;
- if (const qsizetype joinedSize = QByteArrayList_joinedSize(that, sep.size()))
+ if (const qsizetype joinedSize = QByteArrayList_joinedSize(that, seplen))
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);
+ res.append(sep, seplen);
res += that->at(i);
}
return res;
diff --git a/src/corelib/text/qbytearraylist.h b/src/corelib/text/qbytearraylist.h
index c4985047fa..de5546c8ce 100644
--- a/src/corelib/text/qbytearraylist.h
+++ b/src/corelib/text/qbytearraylist.h
@@ -58,10 +58,10 @@ typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
#ifndef Q_CLANG_QDOC
namespace QtPrivate {
-#if QT_REMOVED_SINCE(6, 3)
+#if QT_REMOVED_SINCE(6, 3) && QT_POINTER_SIZE != 4
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);
+ QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *sep, qsizetype len);
}
#endif
@@ -82,7 +82,7 @@ public:
QByteArray join(QByteArrayView sep = {}) const
{
- return QtPrivate::QByteArrayList_join(self(), sep);
+ return QtPrivate::QByteArrayList_join(self(), sep.data(), sep.size());
}
Q_WEAK_OVERLOAD
inline QByteArray join(const QByteArray &sep) const