Re: [PATCH] xdiff: improve trimming preprocessing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 6, 2018 at 6:53 AM, Jun Wu <quark@xxxxxx> 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@xxxxxx>
> ---
> 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++)



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux