QString: add internal qt_compare_strings(QL1S, QSV)

... and adapt qCompareString(QLatin1String, QStringView) to call it
instead of performing the negation itself.

This function will be needed for QLatin1String::startsWith(QStringView).

Change-Id: I8f19dfe0c5274a80c88b43d05f9efda8a91eac46
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2017-04-24 10:48:43 +02:00
parent 979f9f4d34
commit e8085de216

View File

@ -693,6 +693,11 @@ static int qt_compare_strings(QStringView lhs, QLatin1String rhs, Qt::CaseSensit
return ucstricmp(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
}
static int qt_compare_strings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
{
return -qt_compare_strings(rhs, lhs, cs);
}
static int qt_compare_strings(QLatin1String lhs, QLatin1String rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
{
if (lhs.isEmpty())
@ -761,7 +766,7 @@ int qCompareStrings(QStringView lhs, QLatin1String rhs, Qt::CaseSensitivity cs)
*/
int qCompareStrings(QLatin1String lhs, QStringView rhs, Qt::CaseSensitivity cs) Q_DECL_NOTHROW
{
return -qt_compare_strings(rhs, lhs, cs);
return qt_compare_strings(lhs, rhs, cs);
}
/*!