Aaron Stone wrote:
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.
Refactoring practice would have you:
setup test-cases for both.
make one a simple wrapper for the other
and finally remove the wrapper version from the codebase
don't you be shy now, boy.
Select your target, move decisively with confidence, precision and joy... And
always cover your six.
And I'm not kidding about those test-cases. I know I venture into new sections of the code with greater
confidence, using them. Please take a look at check_dbmail_imapd.c.
I would prefer a dbmail-mailbox.c to handle the mailbox model-view-controller code. Rework the api there, and
phase in the new api in the old code. Which is how I'm very gradually phasing in the new mime code.
--
________________________________________________________________
Paul Stevens mailto:[EMAIL PROTECTED]
NET FACILITIES GROUP PGP: finger [EMAIL PROTECTED]
The Netherlands________________________________http://www.nfg.nl