summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qbytearraylist.h
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2018-10-25 11:07:58 +0200
committerDavid Faure <david.faure@kdab.com>2018-11-06 09:49:10 +0000
commitfc88dd52a42da682cbd360916be7c9f94a69b72c (patch)
treef658891358cf0ef572672386c187783ffffd7ff9 /src/corelib/tools/qbytearraylist.h
parenta76f8caf29c9acf83f12dfe90f68cd3f13e45456 (diff)
QByteArrayList: add indexOf(const char*) overload
This avoids memory allocation and data copying in e.g. QObject::property(). Detected by heaptrack's "Temporary allocations" counter in an application using the breeze widget style (many animations). Change-Id: Iabdb58a3e504cb121cce906ef707b0722de89df6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qbytearraylist.h')
-rw-r--r--src/corelib/tools/qbytearraylist.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/corelib/tools/qbytearraylist.h b/src/corelib/tools/qbytearraylist.h
index be94bc1d40..d69e8bb54b 100644
--- a/src/corelib/tools/qbytearraylist.h
+++ b/src/corelib/tools/qbytearraylist.h
@@ -55,6 +55,7 @@ typedef QList<QByteArray> QByteArrayList;
namespace QtPrivate {
QByteArray Q_CORE_EXPORT QByteArrayList_join(const QByteArrayList *that, const char *separator, int separatorLength);
+ int Q_CORE_EXPORT QByteArrayList_indexOf(const QByteArrayList *that, const char *needle, int from);
}
#endif
@@ -76,6 +77,9 @@ public:
inline QByteArray join(char sep) const
{ return QtPrivate::QByteArrayList_join(self(), &sep, 1); }
+ inline int indexOf(const char *needle, int from = 0) const
+ { return QtPrivate::QByteArrayList_indexOf(self(), needle, from); }
+
private:
typedef QList<QByteArray> Self;
Self *self() { return static_cast<Self *>(this); }