From: Jonathan Nieder <jrnieder@gmail.com>
To: Yann Dirson <ydirson@altern.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] Start to replace locate_rename_dst() with a generic function.
Date: Thu, 4 Nov 2010 15:45:55 -0500 [thread overview]
Message-ID: <20101104204555.GA18187@burratino> (raw)
In-Reply-To: <1288902795-8597-2-git-send-email-ydirson@altern.org>
Yann Dirson wrote:
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> @@ -6,6 +6,10 @@
> #include "diffcore.h"
> #include "hash.h"
>
> +#define locate_element(list,elem,insert_ok) \
> + _locate_element(elem, &list##_nr, &list##_alloc, \
> + insert_ok)
> +
Is this syntactic sugar needed?
static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
insert_ok)
{
return locate_element(&rename_dst_nr, &rename_dst_alloc, elem, insert_ok);
}
takes more advantage of the compiler's typechecking and looks easy
enough to read.
Since this is local to diffcore-rename, I don't mind the locate_element()
name, but if this is to be used more widely I think it would need to be
named more precisely. (find_or_insert_in_array()?)
> @@ -13,14 +17,17 @@ static struct diff_rename_dst {
[...]
> -static struct diff_rename_dst *locate_rename_dst(struct diff_filespec *two,
> - int insert_ok)
> +static struct diff_rename_dst *_locate_element(struct diff_filespec *two,
> + int *elem_nr_p, int *elem_alloc_p,
> + int insert_ok)
> {
> int first, last;
>
> first = 0;
> - last = rename_dst_nr;
> + last = (*elem_nr_p);
I guess these parentheses came from search+replace? It's more
readable without them.
[...]
> + (*elem_nr_p)++;
Except for this one.
Generally, the approach seems sane so far.
next prev parent reply other threads:[~2010-11-04 20:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-04 20:33 [RFC PATCH] generalizing sorted-array handling Yann Dirson
2010-11-04 20:33 ` [PATCH 1/4] Start to replace locate_rename_dst() with a generic function Yann Dirson
2010-11-04 20:45 ` Jonathan Nieder [this message]
2010-11-04 21:22 ` Yann Dirson
2010-11-04 20:33 ` [PATCH 2/4] Abstract _locate_element() some more with elem_size parameter Yann Dirson
2010-11-04 20:33 ` [PATCH 3/4] Introduce "abstract class" to make _locate_element() more independant of diff_rename_dst Yann Dirson
2010-11-04 20:56 ` Jonathan Nieder
2010-11-04 20:33 ` [PATCH 4/4] Remove remaining rename_dst references in _locate_element() and pass a pointer to it Yann Dirson
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101104204555.GA18187@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=ydirson@altern.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.
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 NNTP newsgroup(s).