unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Carl Worth <cworth@cworth.org>
To: david@tethera.net, notmuch@notmuchmail.org
Cc: David Bremner <bremner@unb.ca>
Subject: Re: [PATCH] notmuch-restore.c: only update tags for messages that differ from dump file.
Date: Tue, 08 Dec 2009 01:50:51 -0800	[thread overview]
Message-ID: <87ws0x23r8.fsf@yoom.home.cworth.org> (raw)
In-Reply-To: <1260242088-15680-1-git-send-email-david@tethera.net>

[-- Attachment #1: Type: text/plain, Size: 3001 bytes --]

On Mon,  7 Dec 2009 23:14:48 -0400, david@tethera.net 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 to
> 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) && i<tag_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; i<tag_count; i++) {

More missing space. Should be:

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

-Carl

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.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2009-12-08  9:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-06 18:30 [PATCH] notmuch-restore.c: only update tags for messages that differ from dump file david
2009-12-08  3:14 ` david
2009-12-08  6:26   ` Scott Robinson
2009-12-08  9:50   ` Carl Worth [this message]
2009-12-08 22:07     ` david
2010-03-09 18:40       ` Carl Worth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ws0x23r8.fsf@yoom.home.cworth.org \
    --to=cworth@cworth.org \
    --cc=bremner@unb.ca \
    --cc=david@tethera.net \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).