summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2017-03-30 19:13:58 +0200
committerMarc Mutz <marc.mutz@kdab.com>2017-04-12 06:46:12 +0000
commit11ed95ac9c12ee2b20b5c6f6be68d0b6387c0e70 (patch)
tree35acec902de450351ef0e669353e8eeb2230350d /src/corelib/tools
parentcdc5f47aeba94ba083a81dc681a09a351809e528 (diff)
Improve QStringBuilder docs
- Mention you can build QByteArrays, too - Nicer list of types that can be used, separate for QByteArray and QString Change-Id: Ia91445f0cb4872bab12a55f4812c283e9c38dba4 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r--src/corelib/tools/qstringbuilder.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index de12de19cb..70152a9202 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
\reentrant
\since 4.6
- \brief The QStringBuilder class is a template class that provides a facility to build up QStrings from smaller chunks.
+ \brief The QStringBuilder class is a template class that provides a facility to build up QStrings and QByteArrays from smaller chunks.
\ingroup tools
\ingroup shared
@@ -58,22 +58,34 @@ QT_BEGIN_NAMESPACE
To build a QString by multiple concatenations, QString::operator+()
- is typically used. This causes \e{n - 1} reallocations when building
- a string from \e{n} chunks.
+ is typically used. This causes \e{n - 1} allocations when building
+ a string from \e{n} chunks. The same is true for QByteArray.
QStringBuilder uses expression templates to collect the individual
chunks, compute the total size, allocate the required amount of
- memory for the final QString object, and copy the chunks into the
+ memory for the final string object, and copy the chunks into the
allocated memory.
The QStringBuilder class is not to be used explicitly in user
code. Instances of the class are created as return values of the
- operator%() function, acting on objects of type QString,
- QLatin1String, QStringRef, QChar, QCharRef,
- QLatin1Char, and \c char.
+ operator%() function, acting on objects of the following types:
+
+ For building QStrings:
+
+ \li QString, QStringRef,
+ \li QChar, QCharRef, QLatin1Char,
+ \li QLatin1String,
+ \li QByteArray, \c char, \c{const char[]}.
+
+ The types in the last list point are only available when
+ QT_NO_CAST_FROM_ASCII is not defined.
+
+ For building QByteArrays:
+
+ \li QByteArray, \c char, \c{const char[]}.
Concatenating strings with operator%() generally yields better
- performance then using \c QString::operator+() on the same chunks
+ performance than using \c QString::operator+() on the same chunks
if there are three or more of them, and performs equally well in other
cases.