2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Use QDataStream directly on QByteArray.

This commit is contained in:
John Preston
2017-08-08 20:25:10 +02:00
parent dd9d604966
commit edbc3f8fde
6 changed files with 9 additions and 44 deletions

View File

@@ -247,13 +247,7 @@ QByteArray DcOptions::serialize() const {
auto result = QByteArray();
result.reserve(size);
{
QBuffer buffer(&result);
if (!buffer.open(QIODevice::WriteOnly)) {
LOG(("MTP Error: Can't open data for DcOptions::serialize()"));
return result;
}
QDataStream stream(&buffer);
QDataStream stream(&result, QIODevice::WriteOnly);
stream.setVersion(QDataStream::Qt_5_1);
stream << qint32(_data.size());
for (auto &item : _data) {
@@ -273,13 +267,7 @@ QByteArray DcOptions::serialize() const {
}
void DcOptions::constructFromSerialized(const QByteArray &serialized) {
auto readonly = serialized;
QBuffer buffer(&readonly);
if (!buffer.open(QIODevice::ReadOnly)) {
LOG(("MTP Error: Can't open data for DcOptions::constructFromSerialized()"));
return;
}
QDataStream stream(&buffer);
QDataStream stream(serialized);
stream.setVersion(QDataStream::Qt_5_1);
auto count = qint32(0);
stream >> count;