summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qstring.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2018-10-25 07:21:05 +0200
committerLiang Qi <liang.qi@qt.io>2018-10-25 07:21:53 +0200
commite28e91ae99b8c3859899e04cc9370534c7c7b86d (patch)
treecca81b1e745be4f25aab78e8e917c2324594e539 /src/corelib/tools/qstring.cpp
parent5ea233ca6782eb27adf596515cb66ef3dadc1d5e (diff)
parentebfad73b4e44fe6db8059200da105b4b87888718 (diff)
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts: src/corelib/animation/qpropertyanimation.cpp src/gui/image/qicon.cpp tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp Change-Id: I3698172b7b44ebb487cb38f50fd2c4a9f8a35b21
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r--src/corelib/tools/qstring.cpp26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 20cc799d31..03fc10ed07 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -711,9 +711,15 @@ static void qt_to_latin1_internal(uchar *dst, const ushort *src, qsizetype lengt
}
length = length % 4;
+# else
+ length = length % 16;
+# endif // optimize size
+
+ // advance dst, src for tail processing
dst += offset;
src += offset;
+# if !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<3>::exec(length, [=](int i) {
if (Checked)
dst[i] = (src[i]>0xff) ? '?' : (uchar) src[i];
@@ -1072,11 +1078,13 @@ static int ucstrncmp(const QChar *a, const uchar *c, size_t l)
// still matched
offset += 4;
}
+# endif // optimize size
// reset uc and c
uc += offset;
c += offset;
+# if !defined(__OPTIMIZE_SIZE__)
const auto lambda = [=](size_t i) { return uc[i] - ushort(c[i]); };
return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda);
# endif
@@ -7966,10 +7974,7 @@ QVector<QStringRef> QString::splitRef(const QRegularExpression &re, SplitBehavio
Example:
- \code
- QString str("ab");
- str.repeated(4); // returns "abababab"
- \endcode
+ \snippet code/src_corelib_tools_qstring.cpp 8
*/
QString QString::repeated(int times) const
{
@@ -12096,10 +12101,7 @@ QString QString::toHtmlEscaped() const
If you have code that looks like this:
- \code
- // hasAttribute takes a QString argument
- if (node.hasAttribute("http-contents-length")) //...
- \endcode
+ \snippet code/src_corelib_tools_qstring.cpp 9
then a temporary QString will be created to be passed as the \c{hasAttribute}
function parameter. This can be quite expensive, as it involves a memory
@@ -12108,9 +12110,7 @@ QString QString::toHtmlEscaped() const
This cost can be avoided by using QStringLiteral instead:
- \code
- if (node.hasAttribute(QStringLiteral(u"http-contents-length"))) //...
- \endcode
+ \snippet code/src_corelib_tools_qstring.cpp 10
In this case, QString's internal data will be generated at compile time; no
conversion or allocation will occur at runtime.
@@ -12125,9 +12125,7 @@ QString QString::toHtmlEscaped() const
instance, QString::operator==() can compare to a QLatin1String
directly:
- \code
- if (attribute.name() == QLatin1String("http-contents-length")) //...
- \endcode
+ \snippet code/src_corelib_tools_qstring.cpp 11
\note Some compilers have bugs encoding strings containing characters outside
the US-ASCII character set. Make sure you prefix your string with \c{u} in