From 05f22d6eb287e732205fd0869a68a747781b6a35 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 25 Apr 2017 14:53:40 -0300 Subject: QtCore: include mocs Compilation and link times in CPU seconds with GCC 7, using precompiled headers (not including moc, rcc, uic, etc. steps or headersclean): Before After Debug -O0 198,1 180,3 Debug -Og 240,7 229,2 Release -O3 267,1 249,2 Release LTO 239,4 229,8 QtCore required a little manual adjusting because some files are bootstrapped into moc itself and into qmake. Change-Id: I84e363d735b443cb9beefffd14b8b57c10e7da36 Reviewed-by: Lars Knoll Reviewed-by: Marc Mutz Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qlocale.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/corelib/tools/qlocale.cpp') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 697e0062dd..5eb45f3b2c 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3665,3 +3665,7 @@ QDebug operator<<(QDebug dbg, const QLocale &l) } #endif QT_END_NAMESPACE + +#ifndef QT_NO_QOBJECT +#include "moc_qlocale.cpp" +#endif -- cgit v1.2.3 From 37274744212216f8792c2220faaebfb1e40d1327 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 20 Apr 2017 15:43:01 +0200 Subject: Prevent 2 unnecessary QString allocations for QString::number(0u) QLocaleData::unsLongLongToString uses qulltoa, which will allocate a zero-length QArrayData. Then with padding a single 0 was put in a QString, which gets prepended to the result. By taking care of this special case, we can now also fast-path the common case where base=10 and no flags nor precision was provided. Change-Id: Ia893b0ea4c77634c24e7cef5aafb06d0ef44c507 Reviewed-by: Lars Knoll Reviewed-by: Thiago Macieira --- src/corelib/tools/qlocale.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/corelib/tools/qlocale.cpp') diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp index 5eb45f3b2c..dcdf6b5ed7 100644 --- a/src/corelib/tools/qlocale.cpp +++ b/src/corelib/tools/qlocale.cpp @@ -3005,14 +3005,18 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, int base, int width, unsigned flags) { + const QChar resultZero = base == 10 ? zero : QChar(QLatin1Char('0')); + QString num_str = l ? qulltoa(l, base, zero) : QString(resultZero); + bool precision_not_specified = false; if (precision == -1) { + if (flags == NoFlags) + return num_str; // fast-path: nothing below applies, so we're done. + precision_not_specified = true; precision = 1; } - QString num_str = qulltoa(l, base, zero); - uint cnt_thousand_sep = 0; if (flags & ThousandsGroup && base == 10) { for (int i = num_str.length() - 3; i > 0; i -=3) { @@ -3021,7 +3025,6 @@ QString QLocaleData::unsLongLongToString(const QChar zero, const QChar group, } } - const QChar resultZero = base == 10 ? zero : QChar(QLatin1Char('0')); const int zeroPadding = precision - num_str.length()/* + cnt_thousand_sep*/; if (zeroPadding > 0) num_str.prepend(QString(zeroPadding, resultZero)); -- cgit v1.2.3