git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] xdiff: improve trimming preprocessing

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Mar 6, 2018, 19:23 UTC
Message-ID
<CAPig+cRYsf161-Xomw7daj8XdEBxZAEQQRdOn4krRTpSAFkPOw@mail.gmail.com>
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...
Show 10 quoted lines
> 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.
Show 6 quoted lines
> +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.
Show 9 quoted lines
> 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++)
Previous: Jun WuNext: Junio C Hamano
Message 2 of 7 in “xdiff: improve trimming preprocessing”
  1. xdiff: improve trimming preprocessingJun Wu, Mar 6, 2018
  2. Eric SunshineMar 6, 2018
  3. Junio C HamanoMar 6, 2018
  4. Jun WuMar 6, 2018
  5. Jun WuMar 6, 2018
  6. Eric SunshineMar 7, 2018
  7. René ScharfeMar 7, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.