xdiff: rename rindex -> reference_index

The classic diff adds only the lines that it's going to consider, during the diff, to an array. A mapping between the compacted array, and the lines of the file that they reference, is facilitated by this array. Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ezekiel Newren committed Nov 18, 2025 at 22:34 UTC 22ce0cb6397d3d15c21c217696f262c4b8eb44b3
3 files changed +9 -9
xdiff/xdiffi.c
+3 -3
@@ -24,7 +24,7 @@
24
25 static size_t get_hash(xdfile_t *xdf, long index)
26 {
27 - return xdf->recs[xdf->rindex[index]].minimal_perfect_hash;
27 + return xdf->recs[xdf->reference_index[index]].minimal_perfect_hash;
28 }
29
30 #define XDL_MAX_COST_MIN 256
@@ -278,10 +278,10 @@ int xdl_recs_cmp(xdfile_t *xdf1, long off1, long lim1,
278 */
279 if (off1 == lim1) {
280 for (; off2 < lim2; off2++)
281 - xdf2->changed[xdf2->rindex[off2]] = true;
281 + xdf2->changed[xdf2->reference_index[off2]] = true;
282 } else if (off2 == lim2) {
283 for (; off1 < lim1; off1++)
284 - xdf1->changed[xdf1->rindex[off1]] = true;
284 + xdf1->changed[xdf1->reference_index[off1]] = true;
285 } else {
286 xdpsplit_t spl;
287 spl.i1 = spl.i2 = 0;
xdiff/xprepare.c
+5 -5
@@ -128,7 +128,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
128
129 static void xdl_free_ctx(xdfile_t *xdf)
130 {
131 - xdl_free(xdf->rindex);
131 + xdl_free(xdf->reference_index);
132 xdl_free(xdf->changed - 1);
133 xdl_free(xdf->recs);
134 }
@@ -141,7 +141,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
141 uint8_t const *blk, *cur, *top, *prev;
142 xrecord_t *crec;
143
144 - xdf->rindex = NULL;
144 + xdf->reference_index = NULL;
145 xdf->changed = NULL;
146 xdf->recs = NULL;
147
@@ -169,7 +169,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
169
170 if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
171 (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)) {
172 - if (!XDL_ALLOC_ARRAY(xdf->rindex, xdf->nrec + 1))
172 + if (!XDL_ALLOC_ARRAY(xdf->reference_index, xdf->nrec + 1))
173 goto abort;
174 }
175
@@ -312,7 +312,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
312 i <= xdf1->dend; i++, recs++) {
313 if (action1[i] == KEEP ||
314 (action1[i] == INVESTIGATE && !xdl_clean_mmatch(action1, i, xdf1->dstart, xdf1->dend))) {
315 - xdf1->rindex[xdf1->nreff++] = i;
315 + xdf1->reference_index[xdf1->nreff++] = i;
316 /* changed[i] remains false, i.e. keep */
317 } else
318 xdf1->changed[i] = true;
@@ -324,7 +324,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd
324 i <= xdf2->dend; i++, recs++) {
325 if (action2[i] == KEEP ||
326 (action2[i] == INVESTIGATE && !xdl_clean_mmatch(action2, i, xdf2->dstart, xdf2->dend))) {
327 - xdf2->rindex[xdf2->nreff++] = i;
327 + xdf2->reference_index[xdf2->nreff++] = i;
328 /* changed[i] remains false, i.e. keep */
329 } else
330 xdf2->changed[i] = true;
xdiff/xtypes.h
+1 -1
@@ -50,7 +50,7 @@ typedef struct s_xdfile {
50 size_t nrec;
51 ptrdiff_t dstart, dend;
52 bool *changed;
53 - size_t *rindex;
53 + size_t *reference_index;
54 size_t nreff;
55 } xdfile_t;
56