From: Ezekiel Newren Date: Sun, 21 Sep 2025 16:07:20 GMT Subject: Re: [PATCH v3 07/10] xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t Message-ID: In-Reply-To: On Sun, Sep 21, 2025 at 7:06 AM Phillip Wood wrote: > > 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. Yes, this is a stepping stone to many more refactorings that I have planned. > 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. I've incorporated your wording into my commit message. > 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. Makes sense. I'll incorporate that.