git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Stefan Beller <sbeller@google.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 3/3] diff: remove dead code
Date: Thu, 08 Sep 2016 14:07:45 -0700	[thread overview]
Message-ID: <xmqqlgz2f6ce.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160907233648.5162-6-sbeller@google.com> (Stefan Beller's message of "Wed, 7 Sep 2016 16:36:48 -0700")

Stefan Beller <sbeller@google.com> writes:

> When `len < 1`, len has to be 0 or negative, emit_line will then remove the
> first character and by then `len` would be negative. As this doesn't
> happen, it is safe to assume it is dead code.
>
> This continues to simplify the code, which was started in b8d9c1a66b
> (2009-09-03,  diff.c: the builtin_diff() deals with only two-file
> comparison).

We look at line[0] to see if it is '@' before this check, which
would have been wrong if "len < 1" were ever true.

>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  diff.c | 8 --------
>  1 file changed, 8 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index 79ad91d..c143019 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1251,14 +1251,6 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
>  		return;
>  	}
>  
> -	if (len < 1) {
> -		emit_line(o, reset, reset, line, len);
> -		if (ecbdata->diff_words
> -		    && ecbdata->diff_words->type == DIFF_WORDS_PORCELAIN)
> -			fputs("~\n", o->file);
> -		return;
> -	}
> -
>  	if (ecbdata->diff_words) {
>  		if (line[0] == '-') {
>  			diff_words_append(line, len,

      reply	other threads:[~2016-09-08 21:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-07 23:36 [PATCH 0/3] preparatory diff improvements for moved color detection Stefan Beller
2016-09-07 23:36 ` [PATCH 1/3] diff.c: use diff_options directly Stefan Beller
2016-09-08  5:33   ` Jacob Keller
2016-09-07 23:36 ` [PATCH 1/2] diff: omit found pointer from emit_callback Stefan Beller
2016-09-07 23:36 ` [PATCH 2/3] " Stefan Beller
2016-09-08 20:53   ` Junio C Hamano
2016-09-07 23:36 ` [PATCH 2/2] diff: remove dead code Stefan Beller
2016-09-07 23:36 ` [PATCH 3/3] " Stefan Beller
2016-09-08 21:07   ` Junio C Hamano [this message]

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: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=xmqqlgz2f6ce.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=sbeller@google.com \
    /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://80x24.org/mirrors/git.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).