diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2014-03-27 14:49:40 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-03-31 22:54:14 +0200 |
commit | 35ed65b1a94ae7c3788b9326775807bef31b0f69 (patch) | |
tree | 9ddaf15f6804382af1faf1ff28c0de6162754673 /src/corelib/tools/qstringlist.cpp | |
parent | adf0db5243c44a66639fc8f5462eb2d38e85bd9f (diff) |
QStringList: use a functor instead of a function pointer for std::sort
A function pointer requires aggressive optimization to inline. A function object
otoh is inlined by compilers two decades old.
Even shaves off 544B in text size off of a -O3 GCC 4.7 QtCore build.
Change-Id: Ibfd41654257360fa0f118701f502e6c23a6c28b3
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/tools/qstringlist.cpp')
-rw-r--r-- | src/corelib/tools/qstringlist.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/tools/qstringlist.cpp b/src/corelib/tools/qstringlist.cpp index a47af4adbd..30be41a4bd 100644 --- a/src/corelib/tools/qstringlist.cpp +++ b/src/corelib/tools/qstringlist.cpp @@ -221,9 +221,14 @@ QT_BEGIN_NAMESPACE integer index. */ -static inline bool caseInsensitiveLessThan(const QString &s1, const QString &s2) -{ - return s1.compare(s2, Qt::CaseInsensitive) < 0; +namespace { +struct CaseInsensitiveLessThan { + typedef bool result_type; + result_type operator()(const QString &s1, const QString &s2) const + { + return s1.compare(s2, Qt::CaseInsensitive) < 0; + } +}; } void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) @@ -231,7 +236,7 @@ void QtPrivate::QStringList_sort(QStringList *that, Qt::CaseSensitivity cs) if (cs == Qt::CaseSensitive) std::sort(that->begin(), that->end()); else - std::sort(that->begin(), that->end(), caseInsensitiveLessThan); + std::sort(that->begin(), that->end(), CaseInsensitiveLessThan()); } |