diff options
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 26 |
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 |