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:
parent
2cb5e4bd43
commit
6099e96d9e
@ -116,6 +116,7 @@ struct ByteData
|
|||||||
|
|
||||||
QByteArray asByteArrayView() const { return QByteArray::fromRawData(byte(), len); }
|
QByteArray asByteArrayView() const { return QByteArray::fromRawData(byte(), len); }
|
||||||
QLatin1String asLatin1() const { return QLatin1String(byte(), len); }
|
QLatin1String asLatin1() const { return QLatin1String(byte(), len); }
|
||||||
|
QUtf8StringView asUtf8StringView() const { return QUtf8StringView(byte(), len); }
|
||||||
QStringView asStringView() const{ return QStringView(utf16(), len / 2); }
|
QStringView asStringView() const{ return QStringView(utf16(), len / 2); }
|
||||||
QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); }
|
QString asQStringRaw() const { return QString::fromRawData(utf16(), len / 2); }
|
||||||
};
|
};
|
||||||
|
@ -413,10 +413,7 @@ static void sortContainer(QCborContainerPrivate *container)
|
|||||||
if (bKey.flags & QtCbor::Element::StringIsUtf16)
|
if (bKey.flags & QtCbor::Element::StringIsUtf16)
|
||||||
return QCborContainerPrivate::compareUtf8(aData, bData->asStringView());
|
return QCborContainerPrivate::compareUtf8(aData, bData->asStringView());
|
||||||
|
|
||||||
// We're missing an explicit UTF-8 to UTF-8 comparison in Qt, but
|
return QtPrivate::compareStrings(aData->asUtf8StringView(), bData->asUtf8StringView());
|
||||||
// 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());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user