summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstringlist.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-05-18 18:38:25 +0200
committerQt by Nokia <qt-info@nokia.com>2012-09-03 13:41:55 +0200
commit68e04c3ac148bcbe71f2deeb7288563f6cdbcab5 (patch)
tree79970daa0b1b7e6393653a5363a6883f4896e66c /src/corelib/tools/qstringlist.h
parent64a8c78538275b8dbb9d2cbbb1f7b06b247fbe6b (diff)
QStringList::join: add an overload taking a single QChar
This overload avoids the needless heap allocation that the traditional overload incurs due to the implicit QChar -> QString conversion involved there. In order to share the implementation between the two overloads, QStringList_join now takes the separator as a (Char*,int) tuple instead of as a QString. Change-Id: I92961f13a3f19099de2a6e2df9f4789a12fc83a0 Reviewed-by: João Abecasis <joao.abecasis@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qstringlist.h')
-rw-r--r--src/corelib/tools/qstringlist.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/corelib/tools/qstringlist.h b/src/corelib/tools/qstringlist.h
index 3e63e30a57..3656b3fa40 100644
--- a/src/corelib/tools/qstringlist.h
+++ b/src/corelib/tools/qstringlist.h
@@ -75,6 +75,7 @@ public:
inline int removeDuplicates();
inline QString join(const QString &sep) const;
+ inline QString join(QChar sep) const;
inline QStringList filter(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
inline bool contains(const QString &str, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
@@ -122,7 +123,7 @@ Q_DECLARE_TYPEINFO(QStringList, Q_MOVABLE_TYPE);
namespace QtPrivate {
void Q_CORE_EXPORT QStringList_sort(QStringList *that, Qt::CaseSensitivity cs);
int Q_CORE_EXPORT QStringList_removeDuplicates(QStringList *that);
- QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QString &sep);
+ QString Q_CORE_EXPORT QStringList_join(const QStringList *that, const QChar *sep, int seplen);
QStringList Q_CORE_EXPORT QStringList_filter(const QStringList *that, const QString &str,
Qt::CaseSensitivity cs);
@@ -161,7 +162,12 @@ inline int QStringList::removeDuplicates()
inline QString QStringList::join(const QString &sep) const
{
- return QtPrivate::QStringList_join(this, sep);
+ return QtPrivate::QStringList_join(this, sep.constData(), sep.length());
+}
+
+inline QString QStringList::join(QChar sep) const
+{
+ return QtPrivate::QStringList_join(this, &sep, 1);
}
inline QStringList QStringList::filter(const QString &str, Qt::CaseSensitivity cs) const