* [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv
[not found] <472ae7e08eedfef5886d0ace935654876091447d.1365090893.git.simon@ruderich.org>
@ 2013-04-04 16:05 ` Simon Ruderich
2013-04-04 17:05 ` Matthieu Moy
2013-04-04 17:49 ` Jeff King
0 siblings, 2 replies; 3+ messages in thread
From: Simon Ruderich @ 2013-04-04 16:05 UTC (permalink / raw)
To: git
Signed-off-by: Simon Ruderich <simon@ruderich.org>
---
diffcore-pickaxe.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index f814a52..c378ea0 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)
}
static void fill_one(struct diff_filespec *one,
- mmfile_t *mf, struct userdiff_driver **textconv)
+ mmfile_t *mf, struct userdiff_driver *textconv)
{
if (DIFF_FILE_VALID(one)) {
- mf->size = fill_textconv(*textconv, one, &mf->ptr);
+ mf->size = fill_textconv(textconv, one, &mf->ptr);
} else {
memset(mf, 0, sizeof(*mf));
}
@@ -101,8 +101,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
textconv_two = get_textconv(p->two);
}
- fill_one(p->one, &mf1, &textconv_one);
- fill_one(p->two, &mf2, &textconv_two);
+ fill_one(p->one, &mf1, textconv_one);
+ fill_one(p->two, &mf2, textconv_two);
if (!mf1.ptr) {
if (!mf2.ptr)
@@ -228,8 +228,8 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,
if (textconv_one == textconv_two && diff_unmodified_pair(p))
return 0;
- fill_one(p->one, &mf1, &textconv_one);
- fill_one(p->two, &mf2, &textconv_two);
+ fill_one(p->one, &mf1, textconv_one);
+ fill_one(p->two, &mf2, textconv_two);
if (!mf1.ptr) {
if (!mf2.ptr)
--
1.8.2
--
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv
2013-04-04 16:05 ` [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv Simon Ruderich
@ 2013-04-04 17:05 ` Matthieu Moy
2013-04-04 17:49 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Matthieu Moy @ 2013-04-04 17:05 UTC (permalink / raw)
To: Simon Ruderich; +Cc: git
Simon Ruderich <simon@ruderich.org> writes:
> --- a/diffcore-pickaxe.c
> +++ b/diffcore-pickaxe.c
> @@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)
> }
>
> static void fill_one(struct diff_filespec *one,
> - mmfile_t *mf, struct userdiff_driver **textconv)
> + mmfile_t *mf, struct userdiff_driver *textconv)
Nice, but perhaps you should elaborate a bit more in the commit message
to say this is a cleanup without real change.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv
2013-04-04 16:05 ` [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv Simon Ruderich
2013-04-04 17:05 ` Matthieu Moy
@ 2013-04-04 17:49 ` Jeff King
1 sibling, 0 replies; 3+ messages in thread
From: Jeff King @ 2013-04-04 17:49 UTC (permalink / raw)
To: Simon Ruderich; +Cc: git
On Thu, Apr 04, 2013 at 06:05:58PM +0200, Simon Ruderich wrote:
> Signed-off-by: Simon Ruderich <simon@ruderich.org>
> ---
> diffcore-pickaxe.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
> index f814a52..c378ea0 100644
> --- a/diffcore-pickaxe.c
> +++ b/diffcore-pickaxe.c
> @@ -75,10 +75,10 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)
> }
>
> static void fill_one(struct diff_filespec *one,
> - mmfile_t *mf, struct userdiff_driver **textconv)
> + mmfile_t *mf, struct userdiff_driver *textconv)
> {
> if (DIFF_FILE_VALID(one)) {
> - mf->size = fill_textconv(*textconv, one, &mf->ptr);
> + mf->size = fill_textconv(textconv, one, &mf->ptr);
> } else {
> memset(mf, 0, sizeof(*mf));
> }
> @@ -101,8 +101,8 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
> textconv_two = get_textconv(p->two);
> }
>
> - fill_one(p->one, &mf1, &textconv_one);
> - fill_one(p->two, &mf2, &textconv_two);
> + fill_one(p->one, &mf1, textconv_one);
> + fill_one(p->two, &mf2, textconv_two);
This is a sensible cleanup, though as I mentioned elsewhere, I think it
would make sense to come first before the other patch.
After this, fill_one is _almost_ identical to just calling
fill_textconv; the exception is that for the !DIFF_FILE_VALID case,
fill_textconv gives us an empty buffer rather than a NULL one.
What do you think of something like this on top (this is on top of your
patches, but again, I would suggest re-ordering your two, so it would
come as patch 2/3):
diffcore-pickaxe.c | 30 ++++++++++--------------------
1 file changed, 10 insertions(+), 20 deletions(-)
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index c378ea0..26ddf00 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -74,16 +74,6 @@ static void diffgrep_consume(void *priv, char *line, unsigned long len)
line[len] = hold;
}
-static void fill_one(struct diff_filespec *one,
- mmfile_t *mf, struct userdiff_driver *textconv)
-{
- if (DIFF_FILE_VALID(one)) {
- mf->size = fill_textconv(textconv, one, &mf->ptr);
- } else {
- memset(mf, 0, sizeof(*mf));
- }
-}
-
static int diff_grep(struct diff_filepair *p, struct diff_options *o,
regex_t *regexp, kwset_t kws)
{
@@ -101,15 +91,15 @@ static int diff_grep(struct diff_filepair *p, struct diff_options *o,
textconv_two = get_textconv(p->two);
}
- fill_one(p->one, &mf1, textconv_one);
- fill_one(p->two, &mf2, textconv_two);
+ mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);
+ mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);
- if (!mf1.ptr) {
- if (!mf2.ptr)
+ if (!DIFF_FILE_VALID(p->one)) {
+ if (!DIFF_FILE_VALID(p->two))
return 0; /* ignore unmerged */
/* created "two" -- does it have what we are looking for? */
hit = !regexec(regexp, mf2.ptr, 1, ®match, 0);
- } else if (!mf2.ptr) {
+ } else if (!DIFF_FILE_VALID(p->two)) {
/* removed "one" -- did it have what we are looking for? */
hit = !regexec(regexp, mf1.ptr, 1, ®match, 0);
} else {
@@ -228,16 +218,16 @@ static int has_changes(struct diff_filepair *p, struct diff_options *o,
if (textconv_one == textconv_two && diff_unmodified_pair(p))
return 0;
- fill_one(p->one, &mf1, textconv_one);
- fill_one(p->two, &mf2, textconv_two);
+ mf1.size = fill_textconv(textconv_one, p->one, &mf1.ptr);
+ mf2.size = fill_textconv(textconv_two, p->two, &mf2.ptr);
- if (!mf1.ptr) {
- if (!mf2.ptr)
+ if (!DIFF_FILE_VALID(p->one)) {
+ if (!DIFF_FILE_VALID(p->two))
ret = 0; /* ignore unmerged */
/* created */
ret = contains(&mf2, o, regexp, kws) != 0;
}
- else if (!mf2.ptr) /* removed */
+ else if (!DIFF_FILE_VALID(p->two)) /* removed */
ret = contains(&mf1, o, regexp, kws) != 0;
else
ret = contains(&mf1, o, regexp, kws) !=
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-04-04 17:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <472ae7e08eedfef5886d0ace935654876091447d.1365090893.git.simon@ruderich.org>
2013-04-04 16:05 ` [PATCH 2/2] diffcore-pickaxe: fill_one() doesn't modify textconv Simon Ruderich
2013-04-04 17:05 ` Matthieu Moy
2013-04-04 17:49 ` Jeff King
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).