git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Eric Sunshine <sunshine@sunshineco.com>
To: Jun Wu <quark@fb.com>
Cc: git <git@vger.kernel.org>
Subject: Re: [PATCH] xdiff: improve trimming preprocessing
Date: Tue, 6 Mar 2018 14:23:46 -0500	[thread overview]
Message-ID: <CAPig+cRYsf161-Xomw7daj8XdEBxZAEQQRdOn4krRTpSAFkPOw@mail.gmail.com> (raw)
In-Reply-To: <1520337165-sup-4504@x1c>

On Tue, Mar 6, 2018 at 6:53 AM, Jun Wu <quark@fb.com> wrote:
> xdiff-interface trims common suffix if ctxlen is 0. Teach it to also
> trim common prefix, and trim less lines if ctxlen > 0. So it can benefit
> the default diff command, as seen by profiling: [...]

A few comments (below) based upon a quick scan of the patch...

> Signed-off-by: Jun Wu <quark@fb.com>
> ---
> diff --git a/t/t4066-diff-trimming.sh b/t/t4066-diff-trimming.sh
> @@ -0,0 +1,49 @@
> +test_expect_success 'setup' '
> +  printf "x\n%.0s" {1..1000} >a &&
> +  printf "x\n%.0s" {1..1001} >b &&
> +  cat >c <<EOF1 && cat >d <<EOF2 &&\
> +  printf "x%.0s" {1..934} >>c &&\
> +  printf "x%.0s" {1..934} >>d # pad common suffix to 1024 bytes

The expression {x..y} is not portable to non-POSIX shells.

> +test_expect_success 'git diff -U0 shifts hunk towards the end' '
> +       test_expect_code 1 git diff -U0 --no-index a b |\
> +    fgrep "@@ -1000,0 +1001 @@" &&
> +       test_expect_code 1 git diff -U0 --no-index b a |\
> +    fgrep "@@ -1001 +1000,0 @@"
> +'

Style: Mix of tabs and spaces for indentation. Please indent only with
tabs throughout the patch.

> diff --git a/xdiff-interface.c b/xdiff-interface.c
> @@ -101,42 +101,64 @@ static int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
> +static void trim_common(mmfile_t *a, mmfile_t *b, long reserved,
> +                       xdemitconf_t *xecfg)
>  {
> +       /* prefix - need line count for xecfg->ptrimmed */
> +       for (i = 0; ++i < smaller && *ap == *bp;) {
> +               lines += (*ap == '\n');
> +               ap++, bp++;

Is there a good reason for not placing 'ap++, bp++' directly in the 'for'?

    for (i = 0; ++i < smaller && *ap == *bp; ap++, bp++)

  reply	other threads:[~2018-03-06 19:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-06 11:53 [PATCH] xdiff: improve trimming preprocessing Jun Wu
2018-03-06 19:23 ` Eric Sunshine [this message]
2018-03-06 19:29   ` Junio C Hamano
2018-03-06 23:59     ` Jun Wu
2018-03-06 23:05   ` Jun Wu
2018-03-07  9:36     ` Eric Sunshine
2018-03-07 14:36       ` René Scharfe

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=CAPig+cRYsf161-Xomw7daj8XdEBxZAEQQRdOn4krRTpSAFkPOw@mail.gmail.com \
    --to=sunshine@sunshineco.com \
    --cc=git@vger.kernel.org \
    --cc=quark@fb.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).