QJsonObject: use the UTF-8 string comparator in sorting

No change, the two functions are identical for case-sensitive
comparison. But this allows us to remove the comment that explained why
we were abusing the Latin1 comparator.

Change-Id: I0e5f6bec596a4a78bd3bfffd16c98bbcac6c9dc9
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Thiago Macieira 2022-01-12 06:19:41 -08:00
parent 2cb5e4bd43
commit 6099e96d9e
2 changed files with 2 additions and 4 deletions

View File

@ -116,6 +116,7 @@ struct ByteData
QByteArray asByteArrayView() const { return QByteArray::fromRawData(byte(), len); }
QLatin1String asLatin1() const { return QLatin1String(byte(), len); }
QUtf8StringView asUtf8StringView() const { return QUtf8StringView(byte(), len); }
QStringView asStringView() const{ return QStringView(utf16(), len / 2); }
QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); }
};

View File

@ -413,10 +413,7 @@ static void sortContainer(QCborContainerPrivate *container)
if (bKey.flags & QtCbor::Element::StringIsUtf16)
return QCborContainerPrivate::compareUtf8(aData, bData->asStringView());
// We're missing an explicit UTF-8 to UTF-8 comparison in Qt, but
// UTF-8 to UTF-8 comparison retains simple byte ordering, so we'll
// abuse the Latin-1 comparison function.
return QtPrivate::compareStrings(aData->asLatin1(), bData->asLatin1());
return QtPrivate::compareStrings(aData->asUtf8StringView(), bData->asUtf8StringView());
}
};