Skip to content

Commit f4ea812

Browse files
ezekielnewrengitster
authored andcommitted
xdiff: delete struct diffdata_t
Every field in this struct is an alias for a certain field in xdfile_t. diffdata_t.nrec -> xdfile_t.nreff diffdata_t.ha -> xdfile_t.ha diffdata_t.rindex -> xdfile_t.rindex diffdata_t.rchg -> xdfile_t.rchg I think this struct existed before xdfile_t, and was kept for backward compatibility reasons. I think xdiffi should have been refactored to use the new (xdfile_t) struct, but was easier to alias it instead. The local variables rchg* and rindex* don't shorten the lines by much, nor do they really need to be there to make the code more readable. Delete them. Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7c6ce2e commit f4ea812

File tree

2 files changed

+10
-33
lines changed

2 files changed

+10
-33
lines changed

xdiff/xdiffi.c

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ static long xdl_split(unsigned long const *ha1, long off1, long lim1,
257257
* sub-boxes by calling the box splitting function. Note that the real job
258258
* (marking changed lines) is done in the two boundary reaching checks.
259259
*/
260-
int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
261-
diffdata_t *dd2, long off2, long lim2,
260+
int xdl_recs_cmp(xdfile_t *xdf1, long off1, long lim1,
261+
xdfile_t *xdf2, long off2, long lim2,
262262
long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv) {
263-
unsigned long const *ha1 = dd1->ha, *ha2 = dd2->ha;
263+
unsigned long const *ha1 = xdf1->ha, *ha2 = xdf2->ha;
264264

265265
/*
266266
* Shrink the box by walking through each diagonal snake (SW and NE).
@@ -273,17 +273,11 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
273273
* be obviously changed.
274274
*/
275275
if (off1 == lim1) {
276-
char *rchg2 = dd2->rchg;
277-
long *rindex2 = dd2->rindex;
278-
279276
for (; off2 < lim2; off2++)
280-
rchg2[rindex2[off2]] = 1;
277+
xdf2->rchg[xdf2->rindex[off2]] = 1;
281278
} else if (off2 == lim2) {
282-
char *rchg1 = dd1->rchg;
283-
long *rindex1 = dd1->rindex;
284-
285279
for (; off1 < lim1; off1++)
286-
rchg1[rindex1[off1]] = 1;
280+
xdf1->rchg[xdf1->rindex[off1]] = 1;
287281
} else {
288282
xdpsplit_t spl;
289283
spl.i1 = spl.i2 = 0;
@@ -300,9 +294,9 @@ int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
300294
/*
301295
* ... et Impera.
302296
*/
303-
if (xdl_recs_cmp(dd1, off1, spl.i1, dd2, off2, spl.i2,
297+
if (xdl_recs_cmp(xdf1, off1, spl.i1, xdf2, off2, spl.i2,
304298
kvdf, kvdb, spl.min_lo, xenv) < 0 ||
305-
xdl_recs_cmp(dd1, spl.i1, lim1, dd2, spl.i2, lim2,
299+
xdl_recs_cmp(xdf1, spl.i1, lim1, xdf2, spl.i2, lim2,
306300
kvdf, kvdb, spl.min_hi, xenv) < 0) {
307301

308302
return -1;
@@ -318,7 +312,6 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
318312
long ndiags;
319313
long *kvd, *kvdf, *kvdb;
320314
xdalgoenv_t xenv;
321-
diffdata_t dd1, dd2;
322315
int res;
323316

324317
if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0)
@@ -357,16 +350,7 @@ int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
357350
xenv.snake_cnt = XDL_SNAKE_CNT;
358351
xenv.heur_min = XDL_HEUR_MIN_COST;
359352

360-
dd1.nrec = xe->xdf1.nreff;
361-
dd1.ha = xe->xdf1.ha;
362-
dd1.rchg = xe->xdf1.rchg;
363-
dd1.rindex = xe->xdf1.rindex;
364-
dd2.nrec = xe->xdf2.nreff;
365-
dd2.ha = xe->xdf2.ha;
366-
dd2.rchg = xe->xdf2.rchg;
367-
dd2.rindex = xe->xdf2.rindex;
368-
369-
res = xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec,
353+
res = xdl_recs_cmp(&xe->xdf1, 0, xe->xdf1.nreff, &xe->xdf2, 0, xe->xdf2.nreff,
370354
kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0,
371355
&xenv);
372356
xdl_free(kvd);

xdiff/xdiffi.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,6 @@
2424
#define XDIFFI_H
2525

2626

27-
typedef struct s_diffdata {
28-
long nrec;
29-
unsigned long const *ha;
30-
long *rindex;
31-
char *rchg;
32-
} diffdata_t;
33-
3427
typedef struct s_xdalgoenv {
3528
long mxcost;
3629
long snake_cnt;
@@ -46,8 +39,8 @@ typedef struct s_xdchange {
4639

4740

4841

49-
int xdl_recs_cmp(diffdata_t *dd1, long off1, long lim1,
50-
diffdata_t *dd2, long off2, long lim2,
42+
int xdl_recs_cmp(xdfile_t *xdf1, long off1, long lim1,
43+
xdfile_t *xdf2, long off2, long lim2,
5144
long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv);
5245
int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
5346
xdfenv_t *xe);

0 commit comments

Comments
 (0)