I've been looking at the mailbox listing code (starting from ic_list and
working into db.c) to improve efficiency, and the fix is pretty clear:

ic_list calls db_findmailbox_by_regex, which calls
db_list_mailboxes_by_regex, which does a big SELECT, compares the mailbox
names with the regex, keeps the matching mailboxidnr's, and throws away
the names.

ic_list then loops through the list of mailboxidnr's, and selects three
times for each mailbox: first for the mailbox name, then for is_selectable
then for no_inferiors.

The obvious fix is to keep all of that information from the
dbmail_mailboxes table that was retrieved with list_mailboxes in the first
place. So I'm building a structure to hold that information and eliminate
the loop of three more queries per mailbox.

But, in the process, I'd like to know if there's rhyme or reason for:

int db_findmailbox_by_regex(u64_t owner_idnr, const char *pattern,
                            u64_t ** children, unsigned *nchildren,
                            int only_subscribed);
static int db_list_mailboxes_by_regex(u64_t user_idnr, int
only_subscribed,
                               regex_t * preg,
                               u64_t ** mailboxes,
                               unsigned int *nr_mailboxes);

Yes, they really are the same functions, with different order, and just
with findmailbox_by_regex compiling the regex before calling
list_mailboxes.

I'd like to roll these into one function.

Aaron

Reply via email to