QCollatorSortKey: add some std::move
All implementations of QCollator::sortKey() can benefit from moving their CollatorKeyType into the QCollatorSortKeyPrivate on construction. So make the QCollatorSortKeyPrivate ctor a perfect forwarder for its m_key member, and add std::move() calls where they were missing (in all but one case, lvalues were passed). Make the ctor explicit, as it should have been from the beginning. Change-Id: I2a1cdda5fd23990ace019b963df895c621a1fa85 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
parent
a85b4d79db
commit
0d2791c5f6
@ -145,7 +145,7 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
|
||||
string.size(), (uint8_t *)result.data(), result.size());
|
||||
}
|
||||
result.truncate(size);
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(result)));
|
||||
}
|
||||
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(QByteArray()));
|
||||
|
@ -131,7 +131,7 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
|
||||
ret.size(), &actualSize, ret.data());
|
||||
}
|
||||
ret[actualSize] = 0;
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(ret)));
|
||||
}
|
||||
|
||||
int QCollatorSortKey::compare(const QCollatorSortKey &key) const
|
||||
|
@ -131,9 +131,10 @@ class QCollatorSortKeyPrivate : public QSharedData
|
||||
{
|
||||
friend class QCollator;
|
||||
public:
|
||||
QCollatorSortKeyPrivate(const CollatorKeyType &key)
|
||||
template <typename...T>
|
||||
explicit QCollatorSortKeyPrivate(T &&...args)
|
||||
: QSharedData()
|
||||
, m_key(key)
|
||||
, m_key(std::forward<T>(args)...)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
|
||||
}
|
||||
result.resize(size+1);
|
||||
result[size] = 0;
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(result)));
|
||||
}
|
||||
|
||||
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
|
||||
|
@ -147,7 +147,7 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
|
||||
if (finalSize == 0) {
|
||||
qWarning() << "there were problems when generating the ::sortKey by LCMapStringW with error:" << GetLastError();
|
||||
}
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
|
||||
return QCollatorSortKey(new QCollatorSortKeyPrivate(std::move(ret)));
|
||||
}
|
||||
|
||||
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
|
||||
|
Loading…
Reference in New Issue
Block a user