Re: [PATCH 03/17] xdiff: delete unnecessary fields from xrecord_t and xdfile_t
- From
Elijah Newren <newren@gmail.com>
- Date
- Sep 9, 2025, 08:56 UTC
- Message-ID
- <CABPp-BHWMZ4-T_DfOnS4AP-5qANjtdxasFojicy3w1ZTdoETBQ@mail.gmail.com>
- In-Reply-To
- <7d5e387916eaf4afd40afc85b1678306b8a5f076.1757274320.git.gitgitgadget@gmail.com>
On Sun, Sep 7, 2025 at 12:45 PM Ezekiel Newren via GitGitGadget <gitgitgadget@gmail.com> wrote:
Show 96 quoted lines
>
> From: Ezekiel Newren <ezekielnewren@gmail.com>
>
> xrecord_t.next, xdfile_t.hbits, xdfile_t.rhash are initialized,
> but never used for anything by the code. Remove them.
>
> Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com>
> ---
> xdiff/xprepare.c | 15 ++-------------
> xdiff/xtypes.h | 3 ---
> 2 files changed, 2 insertions(+), 16 deletions(-)
>
> diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
> index 2ed1785b09..91b0ed54e0 100644
> --- a/xdiff/xprepare.c
> +++ b/xdiff/xprepare.c
> @@ -91,8 +91,7 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
> }
>
>
> -static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t **rhash,
> - unsigned int hbits, xrecord_t *rec) {
> +static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
> long hi;
> char const *line;
> xdlclass_t *rcrec;
> @@ -126,10 +125,6 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
>
> rec->ha = (unsigned long) rcrec->idx;
>
> - hi = (long) XDL_HASHLONG(rec->ha, hbits);
> - rec->next = rhash[hi];
> - rhash[hi] = rec;
> -
> return 0;
> }
>
> @@ -137,7 +132,6 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
> static void xdl_free_ctx(xdfile_t *xdf)
> {
>
> - xdl_free(xdf->rhash);
> xdl_free(xdf->rindex);
> xdl_free(xdf->rchg - 1);
> xdl_free(xdf->ha);
> @@ -156,7 +150,6 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
> xdf->ha = NULL;
> xdf->rindex = NULL;
> xdf->rchg = NULL;
> - xdf->rhash = NULL;
> xdf->recs = NULL;
>
> if (xdl_cha_init(&xdf->rcha, sizeof(xrecord_t), narec / 4 + 1) < 0)
> @@ -164,10 +157,6 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
> if (!XDL_ALLOC_ARRAY(xdf->recs, narec))
> goto abort;
>
> - xdf->hbits = xdl_hashbits((unsigned int) narec);
> - if (!XDL_CALLOC_ARRAY(xdf->rhash, 1 << xdf->hbits))
> - goto abort;
> -
> xdf->nrec = 0;
> if ((cur = blk = xdl_mmfile_first(mf, &bsize))) {
> for (top = blk + bsize; cur < top; ) {
> @@ -181,7 +170,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
> crec->size = (long) (cur - prev);
> crec->ha = hav;
> xdf->recs[xdf->nrec++] = crec;
> - if (xdl_classify_record(pass, cf, xdf->rhash, xdf->hbits, crec) < 0)
> + if (xdl_classify_record(pass, cf, crec) < 0)
> goto abort;
> }
> }
> diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h
> index 8442bd436e..8b8467360e 100644
> --- a/xdiff/xtypes.h
> +++ b/xdiff/xtypes.h
> @@ -39,7 +39,6 @@ typedef struct s_chastore {
> } chastore_t;
>
> typedef struct s_xrecord {
> - struct s_xrecord *next;
> char const *ptr;
> long size;
> unsigned long ha;
> @@ -48,8 +47,6 @@ typedef struct s_xrecord {
> typedef struct s_xdfile {
> chastore_t rcha;
> long nrec;
> - unsigned int hbits;
> - xrecord_t **rhash;
> long dstart, dend;
> xrecord_t **recs;
> char *rchg;
> --
> gitgitgadgetAlways nice to see unused fields get removed.