summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2015-02-19 22:35:25 -0800
committerThiago Macieira <thiago.macieira@intel.com>2015-03-15 19:00:38 +0000
commitcd1e045b3bbf4b3e73baf1cbd60d5131d8691fd5 (patch)
tree17bf353e7a93fdac5bbe72991cc2238591b96f29 /src/corelib
parentd1cd75e81af809a46fcf40cd2b39858e238a4d97 (diff)
QString: Don't force unrolling of the tail loop if optimizing for size
This is quite good if space isn't a constraint: the unrolling ensures faster execution and limits the number of iterations. But it's long. Both Clang and GCC set the predefined macro __OPTIMIZE_SIZE__ if -Os is in effect. ICC does not; MSVC is untested but there are no macros for this effect listed in its documentation. Change-Id: I1a800c709d3543699131ffff13c48919a9a79ec3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/tools/qstring.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index fb7158c5f2..e74a8eebee 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1,7 +1,7 @@
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
-** Copyright (C) 2013 Intel Corporation
+** Copyright (C) 2015 Intel Corporation
** Contact: http://www.qt.io/licensing/
**
** This file is part of the QtCore module of the Qt Toolkit.
@@ -158,7 +158,7 @@ static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
static inline bool qt_ends_with(const QChar *haystack, int haystackLen,
QLatin1String needle, Qt::CaseSensitivity cs);
-#ifdef Q_COMPILER_LAMBDA
+#if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
namespace {
template <uint MaxCount> struct UnrollTailLoop
{
@@ -239,7 +239,7 @@ void qt_from_latin1(ushort *dst, const char *str, size_t size)
size = size % 16;
dst += offset;
str += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<15>::exec(int(size), [=](int i) { dst[i] = (uchar)str[i]; });
# endif
#endif
@@ -332,7 +332,7 @@ static void qt_to_latin1(uchar *dst, const ushort *src, int length)
dst += offset;
src += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<15>::exec(length, [=](int i) { dst[i] = (src[i]>0xff) ? '?' : (uchar) src[i]; });
# endif
#elif defined(__ARM_NEON__)
@@ -470,7 +470,7 @@ static int ucstrncmp(const QChar *a, const QChar *b, int l)
- reinterpret_cast<const QChar *>(ptr + distance + idx)->unicode();
}
}
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
const auto &lambda = [=](int i) -> int {
return reinterpret_cast<const QChar *>(ptr)[i].unicode()
- reinterpret_cast<const QChar *>(ptr + distance)[i].unicode();
@@ -602,7 +602,7 @@ static int ucstrncmp(const QChar *a, const uchar *c, int l)
uc += offset;
c += offset;
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
const auto &lambda = [=](int i) { return uc[i] - ushort(c[i]); };
return UnrollTailLoop<MaxTailLength>::exec(e - uc, 0, lambda, lambda);
# endif
@@ -684,7 +684,7 @@ static int findChar(const QChar *str, int len, QChar ch, int from,
}
}
-# ifdef Q_COMPILER_LAMBDA
+# if defined(Q_COMPILER_LAMBDA) && !defined(__OPTIMIZE_SIZE__)
return UnrollTailLoop<7>::exec(e - n, -1,
[=](int i) { return n[i] == c; },
[=](int i) { return n - s + i; });