ImapSet: optimize the set before serialization

Authored by dvratil on Apr 20 2020, 10:50 AM.

Description

ImapSet: optimize the set before serialization

Summary:
Client code usually generates the ImapSet by simply passing it a vector of
IDs or just by calling ImapSet::add() in a for loop for individual IDs. This
creates potentially massive amount of intervals. This change ads a method
that will optimize the ImapSet by merging adjacent or overlapping intervals.

I ran into this trying to move about 28'000 emails to Trash in KMail. The IMAP
resource calls ImapSet::add() in a for loop to add each Item to be moved into
the set. This just created 28'000 single-UID intervals and the resulting request
string was so long that my Courier IMAP server just dropped the connection, so
the IMAP resource reconnected and tried to send the same massive request again
and again and again...

By optimizing the set the string size is reduced from nearly 156 kilobytes
down to less than 4 kilobytes.

Reviewers: KDE PIM, vkrause

Reviewed By: KDE PIM, vkrause

Subscribers: kde-pim

Tags: KDE PIM

Differential Revision: https://phabricator.kde.org/D28944

Details

Committed
dvratilApr 20 2020, 10:52 AM
Reviewer
KDE PIM
Differential Revision
D28944: ImapSet: optimize the set before serialization
Parents
R177:4da8833cdf79: GIT_SILENT: add flags for compiling without slots/emit etc.
Branches
Unknown
Tags
Unknown