Git fork

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>

authored by

Ezekiel Newren and committed by
Junio C Hamano
f4ea812b 7c6ce2e4

+10 -33
+8 -24
xdiff/xdiffi.c
··· 257 257 * sub-boxes by calling the box splitting function. Note that the real job 258 258 * (marking changed lines) is done in the two boundary reaching checks. 259 259 */ 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, 262 262 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; 264 264 265 265 /* 266 266 * Shrink the box by walking through each diagonal snake (SW and NE). ··· 273 273 * be obviously changed. 274 274 */ 275 275 if (off1 == lim1) { 276 - char *rchg2 = dd2->rchg; 277 - long *rindex2 = dd2->rindex; 278 - 279 276 for (; off2 < lim2; off2++) 280 - rchg2[rindex2[off2]] = 1; 277 + xdf2->rchg[xdf2->rindex[off2]] = 1; 281 278 } else if (off2 == lim2) { 282 - char *rchg1 = dd1->rchg; 283 - long *rindex1 = dd1->rindex; 284 - 285 279 for (; off1 < lim1; off1++) 286 - rchg1[rindex1[off1]] = 1; 280 + xdf1->rchg[xdf1->rindex[off1]] = 1; 287 281 } else { 288 282 xdpsplit_t spl; 289 283 spl.i1 = spl.i2 = 0; ··· 300 294 /* 301 295 * ... et Impera. 302 296 */ 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, 304 298 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, 306 300 kvdf, kvdb, spl.min_hi, xenv) < 0) { 307 301 308 302 return -1; ··· 318 312 long ndiags; 319 313 long *kvd, *kvdf, *kvdb; 320 314 xdalgoenv_t xenv; 321 - diffdata_t dd1, dd2; 322 315 int res; 323 316 324 317 if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) ··· 357 350 xenv.snake_cnt = XDL_SNAKE_CNT; 358 351 xenv.heur_min = XDL_HEUR_MIN_COST; 359 352 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, 370 354 kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, 371 355 &xenv); 372 356 xdl_free(kvd);
+2 -9
xdiff/xdiffi.h
··· 24 24 #define XDIFFI_H 25 25 26 26 27 - typedef struct s_diffdata { 28 - long nrec; 29 - unsigned long const *ha; 30 - long *rindex; 31 - char *rchg; 32 - } diffdata_t; 33 - 34 27 typedef struct s_xdalgoenv { 35 28 long mxcost; 36 29 long snake_cnt; ··· 46 39 47 40 48 41 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, 51 44 long *kvdf, long *kvdb, int need_min, xdalgoenv_t *xenv); 52 45 int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, 53 46 xdfenv_t *xe);