Re: [PATCH v3 02/10] xdiff: use ptrdiff_t for dstart/dend
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Nov 11, 2025, 22:23 UTC
- Message-ID
- <xmqqms4sus2w.fsf@gitster.g>
- In-Reply-To
- <52e3f589b1ce25085921453eea14b9c9d7c8f362.1762890152.git.gitgitgadget@gmail.com>
"Ezekiel Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Ezekiel Newren <ezekielnewren@gmail.com> > > ptrdiff_t is appropriate for dstart and dend because they both describe > positive or negative offsets relative to a pointer.
Makes sense.
> A future patch will move these fields to a different struct. Moving > them to the end of xdfile_t now, means the field order of xdfile_t will > be disturbed less.
If these members will be gone from this struct, it wouldn't make any difference in the end. I am not sure what you mean by "disturbed less". Right now there is a gap between changed and nrec members, and at some later point, these two members may be adjacent with each other. I do not think it would make that much difference if they become adjacent after this step [02/10], after step [10/10], or in a separate series (xdiff-cleanup-3?).
Show 21 quoted lines
> Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
> ---
> xdiff/xtypes.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h
> index f145abba3e..7c8c057bca 100644
> --- a/xdiff/xtypes.h
> +++ b/xdiff/xtypes.h
> @@ -47,10 +47,10 @@ typedef struct s_xrecord {
> typedef struct s_xdfile {
> xrecord_t *recs;
> long nrec;
> - long dstart, dend;
> bool *changed;
> long *rindex;
> long nreff;
> + ptrdiff_t dstart, dend;
> } xdfile_t;
>
> typedef struct s_xdfenv {