From: Phillip Wood Date: Sun, 21 Sep 2025 13:07:02 GMT Subject: Re: [PATCH v3 09/10] xdiff: delete rchg aliasing Message-ID: In-Reply-To: Hi Ezekiel What is the purpose of this change. On the face of it it makes the code more verbose and introduces an extra pointer dereference into the loop condition. The compiler may lift the deference out of the loop but it would be helpful to know why this change is useful. Thanks Phillip On 19/09/2025 16:16, Ezekiel Newren via GitGitGadget wrote: > From: Ezekiel Newren > > Best-viewed-with: --color-words > Signed-off-by: Ezekiel Newren > --- > xdiff/xdiffi.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/xdiff/xdiffi.c b/xdiff/xdiffi.c > index a66125d44a..83c4cff6f7 100644 > --- a/xdiff/xdiffi.c > +++ b/xdiff/xdiffi.c > @@ -932,16 +932,15 @@ int xdl_change_compact(xdfile_t *xdf, xdfile_t *xdfo, long flags) { > > int xdl_build_script(xdfenv_t *xe, xdchange_t **xscr) { > xdchange_t *cscr = NULL, *xch; > - char *rchg1 = xe->xdf1.rchg, *rchg2 = xe->xdf2.rchg; > long i1, i2, l1, l2; > > /* > * Trivial. Collects "groups" of changes and creates an edit script. > */ > for (i1 = xe->xdf1.nrec, i2 = xe->xdf2.nrec; i1 >= 0 || i2 >= 0; i1--, i2--) > - if (rchg1[i1 - 1] || rchg2[i2 - 1]) { > - for (l1 = i1; rchg1[i1 - 1]; i1--); > - for (l2 = i2; rchg2[i2 - 1]; i2--); > + if (xe->xdf1.rchg[i1 - 1] || xe->xdf2.rchg[i2 - 1]) { > + for (l1 = i1; xe->xdf1.rchg[i1 - 1]; i1--); > + for (l2 = i2; xe->xdf2.rchg[i2 - 1]; i2--); > > if (!(xch = xdl_add_change(cscr, i1, i2, l1 - i1, l2 - i2))) { > xdl_free_script(cscr);