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>bb10
parent
adf0db5243
commit
35ed65b1a9
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue