Subject: Re: [PATCH v3 07/10] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t

From: Phillip Wood <[email-masked]>
Date: Sun, 21 Sep 2025 14:06:52 +0100

Hi Ezekiol

On 19/09/2025 16:16, Ezekiel Newren via GitGitGadget wrote:
> From: Ezekiel Newren <[email-masked]>
> 
> 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
> 
> Remove aliasing from xdlclass_t, to reduce future refactoring mistakes.

This is a rather nebulous reason. I assume this is about changing the 
types used in xrecord_t in which case it would be helpful to say 
something like

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.

As we're embedding the struct, instead of doing

> -		rcrec->line = line;
> -		rcrec->size = rec->size;
> -		rcrec->ha = rec->ha;
> +		rcrec->rec.ptr = rec->ptr;
> +		rcrec->rec.size = rec->size;
> +		rcrec->rec.ha = rec->ha;

it would be simpler do do

-		rcrec->line = line;
-		rcrec->size = rec->size;
-		rcrec->ha = rec->ha;
+		rcrec->rec = rec;

which would make it clear we're copying all the struct members.

Thanks

Phillip