Optimization in KDE-PIM
Use QVector for passing lists of UIDs
OK, this is a big patch. Stuff started when I was profiling quite a slow
operation of mass expunges which was reported by Luke-jr on IRC. Some
profiling indicated that quite a lot of time was spent within
QListData::append. Adding a call to QList::reserve didn't help that
much, while replacing this with a QVector led to interesting results.
The cache format stays the same -- QDataStream uses the same
serialization format for both, which is cool.
Unfortunately, this change propagated into quite a few places. As I was
modifying the code anyway, I decoded to do it properly, with typedefs
and what not. Of course, QVector and QList have slightly different APIs,
especially the removeOne/removeAll/removeAt vs. just remove (until Qt
5.4 which actually added compatibility API, but we cannot depend on 5.4
The speed improvements suggest going from 2.5 to 1.5s on a synthetic
benchmark, Looking at callgrind's output, the total time spent in
Imap::Mailbox::Model::saveUidMap went from 34% to ~17%, which is IMHO a
pretty cool improvement.
Majority of time is now spent in comparing strings when determining
unread status of flags -- that's the next item on my list, because this
test exercises that code path a lot, again in an O(n^2) manner.