Re: [PATCH v3 07/10] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t
- From
- Phillip Wood <phillip.wood123@gmail.com>
- Date
- Sep 21, 2025, 13:06 UTC
- Message-ID
- <d22c61da-bd78-47cd-b3b6-adc0d3873fef@gmail.com>
- In-Reply-To
- <e1e94107c9722b751d6111460b17e02a7ffd96d1.1758294992.git.gitgitgadget@gmail.com>
Hi Ezekiol
On 19/09/2025 16:16, Ezekiel Newren via GitGitGadget wrote:
Show 8 quoted lines
> From: Ezekiel Newren <ezekielnewren@gmail.com> > > 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
Show 6 quoted lines
> - 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