xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t

The fields from xdlclass_t are aliases of xrecord_t: xdlclass_t.line -> xrecord_t.ptr xdlclass_t.size -> xrecord_t.size xdlclass_t.ha -> xrecord_t.ha xdlclass_t carries a copy of the data in xrecord_t, but instead of embedding xrecord_t it duplicates the individual fields. A future commit will change the types used in xrecord_t so embed it in xdlclass_t first, so we don't have to remember to change the types here as well. Best-viewed-with: --color-words Helped-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ezekiel Newren committed Sep 26, 2025 at 22:41 UTC 6d507bd41a6f57f802a93a134cca0949a3d4370a
1 file changed +4 -10
xdiff/xprepare.c
+4 -10
@@ -32,9 +32,7 @@
32
33 typedef struct s_xdlclass {
34 struct s_xdlclass *next;
35 - unsigned long ha;
36 - char const *line;
37 - long size;
35 + xrecord_t rec;
36 long idx;
37 long len1, len2;
38 } xdlclass_t;
@@ -93,14 +91,12 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
91
92 static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
93 long hi;
96 - char const *line;
94 xdlclass_t *rcrec;
95
99 - line = rec->ptr;
96 hi = (long) XDL_HASHLONG(rec->ha, cf->hbits);
97 for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
102 - if (rcrec->ha == rec->ha &&
103 - xdl_recmatch(rcrec->line, rcrec->size,
98 + if (rcrec->rec.ha == rec->ha &&
99 + xdl_recmatch(rcrec->rec.ptr, rcrec->rec.size,
100 rec->ptr, rec->size, cf->flags))
101 break;
102
@@ -113,9 +109,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
109 if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
110 return -1;
111 cf->rcrecs[rcrec->idx] = rcrec;
116 - rcrec->line = line;
117 - rcrec->size = rec->size;
118 - rcrec->ha = rec->ha;
112 + rcrec->rec = *rec;
113 rcrec->len1 = rcrec->len2 = 0;
114 rcrec->next = cf->rchash[hi];
115 cf->rchash[hi] = rcrec;