Skip to content

Commit 6d507bd

Browse files
ezekielnewrengitster
authored andcommitted
xdiff: delete fields ha, line, size in xdlclass_t in favor of an xrecord_t
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 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. Best-viewed-with: --color-words Helped-by: Phillip Wood <phillip.wood123@gmail.com> Signed-off-by: Ezekiel Newren <ezekielnewren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5c294dc commit 6d507bd

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

xdiff/xprepare.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232

3333
typedef struct s_xdlclass {
3434
struct s_xdlclass *next;
35-
unsigned long ha;
36-
char const *line;
37-
long size;
35+
xrecord_t rec;
3836
long idx;
3937
long len1, len2;
4038
} xdlclass_t;
@@ -93,14 +91,12 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
9391

9492
static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
9593
long hi;
96-
char const *line;
9794
xdlclass_t *rcrec;
9895

99-
line = rec->ptr;
10096
hi = (long) XDL_HASHLONG(rec->ha, cf->hbits);
10197
for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
102-
if (rcrec->ha == rec->ha &&
103-
xdl_recmatch(rcrec->line, rcrec->size,
98+
if (rcrec->rec.ha == rec->ha &&
99+
xdl_recmatch(rcrec->rec.ptr, rcrec->rec.size,
104100
rec->ptr, rec->size, cf->flags))
105101
break;
106102

@@ -113,9 +109,7 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
113109
if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
114110
return -1;
115111
cf->rcrecs[rcrec->idx] = rcrec;
116-
rcrec->line = line;
117-
rcrec->size = rec->size;
118-
rcrec->ha = rec->ha;
112+
rcrec->rec = *rec;
119113
rcrec->len1 = rcrec->len2 = 0;
120114
rcrec->next = cf->rchash[hi];
121115
cf->rchash[hi] = rcrec;

0 commit comments

Comments
 (0)