Allow precompute size of serialized tags.
This commit is contained in:
parent
f46a1be77c
commit
f06346fbf0
2 changed files with 21 additions and 4 deletions
|
|
@ -1950,6 +1950,20 @@ void Trim(TextWithEntities &result) {
|
|||
}
|
||||
}
|
||||
|
||||
int SerializeTagsSize(const TextWithTags::Tags &tags) {
|
||||
auto result = qint32(0);
|
||||
if (tags.isEmpty()) {
|
||||
return result;
|
||||
}
|
||||
result += sizeof(qint32);
|
||||
for (const auto &tag : tags) {
|
||||
result += 2 * sizeof(qint32) // offset, length
|
||||
+ sizeof(quint32) // id.size
|
||||
+ tag.id.size() * sizeof(ushort);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
QByteArray SerializeTags(const TextWithTags::Tags &tags) {
|
||||
if (tags.isEmpty()) {
|
||||
return QByteArray();
|
||||
|
|
|
|||
|
|
@ -344,10 +344,13 @@ inline QString PrepareForSending(const QString &text, PrepareTextOption option =
|
|||
// Replace bad symbols with space and remove '\r'.
|
||||
void ApplyServerCleaning(TextWithEntities &result);
|
||||
|
||||
QByteArray SerializeTags(const TextWithTags::Tags &tags);
|
||||
TextWithTags::Tags DeserializeTags(QByteArray data, int textLength);
|
||||
QString TagsMimeType();
|
||||
QString TagsTextMimeType();
|
||||
[[nodiscard]] int SerializeTagsSize(const TextWithTags::Tags &tags);
|
||||
[[nodiscard]] QByteArray SerializeTags(const TextWithTags::Tags &tags);
|
||||
[[nodiscard]] TextWithTags::Tags DeserializeTags(
|
||||
QByteArray data,
|
||||
int textLength);
|
||||
[[nodiscard]] QString TagsMimeType();
|
||||
[[nodiscard]] QString TagsTextMimeType();
|
||||
|
||||
inline const auto kMentionTagStart = qstr("mention://user.");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue