Skip to content

Commit 5086213

Browse files
phillipwoodgitster
authored andcommitted
xdiff: remove unused data from xdlclass_t
Prior to commit 6d507bd (xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t, 2025-09-26) xdlclass_t carried a copy of all the fields in xrecord_t. That commit embedded xrecord_t in xdlclass_t to make it easier to change the types of the fields in xrecord_t. However commit 6a26019 (xdiff: split xrecord_t.ha into line_hash and minimal_perfect_hash, 2025-11-18) added the "minimal_perfect_hash" field to xrecord_t which is not used by xdlclass_t. To avoid wasting space stop copying the whole of xrecord_t and just copy the pointer and length that we need to intern the line. Together with the previous commit this effectively reverts 6d507bd. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c27afcb commit 5086213

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

xdiff/xprepare.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
typedef struct s_xdlclass {
3737
uint64_t line_hash;
3838
struct s_xdlclass *next;
39-
xrecord_t rec;
39+
const uint8_t *ptr;
40+
size_t size;
4041
long idx;
4142
long len1, len2;
4243
} xdlclass_t;
@@ -101,7 +102,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
101102
hi = XDL_HASHLONG(line_hash, cf->hbits);
102103
for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
103104
if (rcrec->line_hash == line_hash &&
104-
xdl_recmatch((const char *)rcrec->rec.ptr, (long)rcrec->rec.size,
105+
xdl_recmatch((const char *)rcrec->ptr, (long)rcrec->size,
105106
(const char *)rec->ptr, (long)rec->size, cf->flags))
106107
break;
107108

@@ -115,7 +116,8 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
115116
return -1;
116117
cf->rcrecs[rcrec->idx] = rcrec;
117118
rcrec->line_hash = line_hash;
118-
rcrec->rec = *rec;
119+
rcrec->ptr = rec->ptr;
120+
rcrec->size = rec->size;
119121
rcrec->len1 = rcrec->len2 = 0;
120122
rcrec->next = cf->rchash[hi];
121123
cf->rchash[hi] = rcrec;

0 commit comments

Comments
 (0)