public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: David Kastrup <dak@gnu•org>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] builtin/blame.c::find_copy_in_blob: no need to scan for region end
Date: Tue, 25 Feb 2014 09:51:45 -0800	[thread overview]
Message-ID: <xmqq61o36pxq.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1393084967-23408-1-git-send-email-dak@gnu.org> (David Kastrup's message of "Sat, 22 Feb 2014 17:02:47 +0100")

David Kastrup <dak@gnu•org> writes:

> The region end can be looked up just like its beginning.
>
> Signed-off-by: David Kastrup <dak@gnu•org>
> ---
>  builtin/blame.c | 9 +--------
>  1 file changed, 1 insertion(+), 8 deletions(-)

Yay, code reduction!  Thanks.

> diff --git a/builtin/blame.c b/builtin/blame.c
> index e44a6bb..96716dd 100644
> --- a/builtin/blame.c
> +++ b/builtin/blame.c
> @@ -939,7 +939,6 @@ static void find_copy_in_blob(struct scoreboard *sb,
>  			      mmfile_t *file_p)
>  {
>  	const char *cp;
> -	int cnt;
>  	mmfile_t file_o;
>  	struct handle_split_cb_data d;
>  
> @@ -950,13 +949,7 @@ static void find_copy_in_blob(struct scoreboard *sb,
>  	 */
>  	cp = nth_line(sb, ent->lno);
>  	file_o.ptr = (char *) cp;
> -	cnt = ent->num_lines;
> -
> -	while (cnt && cp < sb->final_buf + sb->final_buf_size) {
> -		if (*cp++ == '\n')
> -			cnt--;
> -	}
> -	file_o.size = cp - file_o.ptr;
> +	file_o.size = nth_line(sb, ent->lno + ent->num_lines) - cp;
>  
>  	/*
>  	 * file_o is a part of final image we are annotating.

      reply	other threads:[~2014-02-25 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-22 16:02 [PATCH] builtin/blame.c::find_copy_in_blob: no need to scan for region end David Kastrup
2014-02-25 17:51 ` 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

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

  git send-email \
    --in-reply-to=xmqq61o36pxq.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=dak@gnu$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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