]> git.ipfire.org Git - thirdparty/git.git/commitdiff
xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t
authorEzekiel Newren <ezekielnewren@gmail.com>
Fri, 26 Sep 2025 22:41:55 +0000 (22:41 +0000)
committerJunio C Hamano <gitster@pobox.com>
Tue, 30 Sep 2025 21:12:46 +0000 (14:12 -0700)
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>
xdiff/xprepare.c

index 22c44f06835138a4a25be3182721ff2714eb8b24..e6e2c0e1c05eaf30efca4cf551eec7b60c4f2403 100644 (file)
@@ -32,9 +32,7 @@
 
 typedef struct s_xdlclass {
        struct s_xdlclass *next;
-       unsigned long ha;
-       char const *line;
-       long size;
+       xrecord_t rec;
        long idx;
        long len1, len2;
 } xdlclass_t;
@@ -93,14 +91,12 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
 
 static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
        long hi;
-       char const *line;
        xdlclass_t *rcrec;
 
-       line = rec->ptr;
        hi = (long) XDL_HASHLONG(rec->ha, cf->hbits);
        for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
-               if (rcrec->ha == rec->ha &&
-                               xdl_recmatch(rcrec->line, rcrec->size,
+               if (rcrec->rec.ha == rec->ha &&
+                               xdl_recmatch(rcrec->rec.ptr, rcrec->rec.size,
                                        rec->ptr, rec->size, cf->flags))
                        break;
 
@@ -113,9 +109,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
                if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
                                return -1;
                cf->rcrecs[rcrec->idx] = rcrec;
-               rcrec->line = line;
-               rcrec->size = rec->size;
-               rcrec->ha = rec->ha;
+               rcrec->rec = *rec;
                rcrec->len1 = rcrec->len2 = 0;
                rcrec->next = cf->rchash[hi];
                cf->rchash[hi] = rcrec;