Display matching new messages in a thread-limited index.
Previously, the index performed pattern matching first, and then
resorted new mail. The problem was that thread-limiting patterns,
e.g. ~(pattern), require threading data to properly match against the
new messages.
We already save new messages for the purposes of uncollapsing threads.
To keep the code cleaner, split off update_index() into
update_index_threaded()/unthreaded(). Then for threaded mode, save
the new messages first. We can then sort (before pattern matching),
and use the save_new array to pattern match the new messages
afterwards.
The $uncollapse_new loop was unnecessarily performing a n^2 search.
Simplify to just iteratate over the save_new instead.