Bypass costly PHP message sorting if IMAP server support SORT
|Reported by:||jeblair||Owned by:|
If an IMAP server supports SORT, RoundCube still sorts the message headers in rcube_imap (using the sorter class) nonetheless. This operation can be expensive on large mailboxes. Instead, it should take advantage of the fact that the UIDs it gets from the IMAP server are already sorted. The only part of the code wrapped by if(!$headers_sorted) that needs to be run on output from an IMAP server that supports SORT is potentially reversing the array at the end.
I'm attaching a patch that separates the functionality of sorting and reversing, so that the headers are sorted or reversed only when needed.