Re: [notmuch] [PATCH] notmuch-restore.c: only update tags for messages that differ from dump file.

2010-03-09 Thread Carl Worth
On Tue,  8 Dec 2009 18:07:43 -0400, wrote:
 This is posting 3 of the patch. The second version fixed a bug.  This
 version replaces calloc/realloc with talloc equivalents, prettifies
 the comparison function for qsort, reindents, and adds a bunch of

It's odd that even after reviewing a couple of rounds of this patch, I
then went and forgot about it when I wrote my own version. I could have
saved myself some work otherwise.

Ah well, let me know if you see anything that you think should be
changed in the code that's in place now.



Description: PGP signature
notmuch mailing list

Re: [notmuch] [PATCH] notmuch-restore.c: only update tags for messages that differ from dump file.

2009-12-08 Thread Carl Worth
On Mon,  7 Dec 2009 23:14:48 -0400, wrote:
 The main feature of this patch is that it compares the list of current
 tags on a message with those read by restore. Only if the two lists
 differ is the tag list in the message replaced.  In my experiments this leads 
 a large performance improvement.

Hi David,

This is going to be a nice performance fix. Thanks for working on it!

I noticed that the code is in a style that is inconsistent with the
prevailing style of the notmuch code. So here are a few points on some
obvious style differences (there are other similar issues that I don't
mention specifically).

And I don't mean anything personal here. We all have different styles
that we prefer and find most legible. I do think it's important that the
code be in a consistent style throughout though, (and I will make a
CODING_STYLE document for the source tree soon).

 +/* for qsort */
 +static int scmp( const void *sp1, const void *sp2 )

The function name really needs to be on its own line (flush with the
left-most column). I don't like the interior whitespace for the argument
list. I really don't like a name as dramatically abbreviated as
scmp. I'd prefer something like strcmp_for_qsort or whatever this is
actually doing.

 +return( strcmp(*(const char **)sp1, *(const char **)sp2) );

More whitespace here. There should be a space *before* the '(' not
after, (and then not before the ')'). Finally, with void* arguments, I
like to take care of the ugly casts up front, (assigning to approriately
named local variables) rather than cluttering a function call with casts
like this.

 +char **tag_array=NULL;
 +int tag_array_size=DEFAULT_TAG_ARRAY_SIZE;

Need whitespace on either side of '=' here, (and similar throughout).

 + while(*next){

More missing space. I would prefer:

while (*next) {

 +   while(*next  isspace(*next))
 + next++;

Current indentation in notmuch is 4 columns per indent level, not 2.

 +   tag_array=realloc(tag_array,tag_array_size*sizeof(char *));

I can't read that at all with so much missing space. I'd prefer to see:

  tag_array = realloc (tag_array, tag_array_size * sizeof (char *));

 + while (notmuch_tags_has_more (tag_list)  itag_count 
 +(strcmp(notmuch_tags_get (tag_list),tag_array[i])==0)){
 +   notmuch_tags_advance (tag_list);
 +   i++;
 + }

While I don't mind an opening brace on the same line as an if or
while condition, I do mind it when the condition spans more than one
line. In that case, the opening brace really needs to be on a line of
its own. And again, lots of missing space in the above.

 +   for (i=0; itag_count; i++) {

More missing space. Should be:

  for (i = 0; i  tag_count; i++) {


PS. Why is the commit mentioning using calloc, not talloc? Is there a
reason talloc is inappropriate here? Or were you just not familiar with
how to use it? I'd be glad to answer any questions you have about use of
talloc in notmuch.

Description: PGP signature
notmuch mailing list

Re: [notmuch] [PATCH] notmuch-restore.c: only update tags for messages that differ from dump file.

2009-12-07 Thread Scott Robinson
Excerpts from david's message of Mon Dec 07 19:14:48 -0800 2009:
 The patch allocates a temporary array to keep track of the current
 list of tags using calloc and grows it as neccesary using realloc.

The codebase has already well established the use of the talloc library. Why
did you break with that?
Scott Robinson |

Q: Why are my replies five sentences or less?
notmuch mailing list