aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2026-02-20 11:36:17 -0800
committerJunio C Hamano <gitster@pobox.com>2026-02-20 11:36:17 -0800
commit5465d3683a97a950358152925204f16b98739fad (patch)
tree040bc1268d3084a2b4d399ee84ce3bc06b13af61
parent73fd77805fc6406f31c36212846d9e2541d19321 (diff)
parent5086213bd2f44fdc793fd8a081fd1c40a3267c44 (diff)
downloadgit-5465d3683a97a950358152925204f16b98739fad.tar.xz
Merge branch 'pw/xdiff-cleanups'
Small clean-up of xdiff library to remove unnecessary data duplication. * pw/xdiff-cleanups: xdiff: remove unused data from xdlclass_t xdiff: remove "line_hash" field from xrecord_t
-rw-r--r--xdiff/xprepare.c20
-rw-r--r--xdiff/xtypes.h1
2 files changed, 12 insertions, 9 deletions
diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c
index 34c82e4f8e..cd4fc405eb 100644
--- a/xdiff/xprepare.c
+++ b/xdiff/xprepare.c
@@ -34,8 +34,10 @@
#define INVESTIGATE 2
typedef struct s_xdlclass {
+ uint64_t line_hash;
struct s_xdlclass *next;
- xrecord_t rec;
+ const uint8_t *ptr;
+ size_t size;
long idx;
long len1, len2;
} xdlclass_t;
@@ -92,14 +94,15 @@ static void xdl_free_classifier(xdlclassifier_t *cf) {
}
-static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec) {
+static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t *rec,
+ uint64_t line_hash) {
size_t hi;
xdlclass_t *rcrec;
- hi = XDL_HASHLONG(rec->line_hash, cf->hbits);
+ hi = XDL_HASHLONG(line_hash, cf->hbits);
for (rcrec = cf->rchash[hi]; rcrec; rcrec = rcrec->next)
- if (rcrec->rec.line_hash == rec->line_hash &&
- xdl_recmatch((const char *)rcrec->rec.ptr, (long)rcrec->rec.size,
+ if (rcrec->line_hash == line_hash &&
+ xdl_recmatch((const char *)rcrec->ptr, (long)rcrec->size,
(const char *)rec->ptr, (long)rec->size, cf->flags))
break;
@@ -112,7 +115,9 @@ static int xdl_classify_record(unsigned int pass, xdlclassifier_t *cf, xrecord_t
if (XDL_ALLOC_GROW(cf->rcrecs, cf->count, cf->alloc))
return -1;
cf->rcrecs[rcrec->idx] = rcrec;
- rcrec->rec = *rec;
+ rcrec->line_hash = line_hash;
+ rcrec->ptr = rec->ptr;
+ rcrec->size = rec->size;
rcrec->len1 = rcrec->len2 = 0;
rcrec->next = cf->rchash[hi];
cf->rchash[hi] = rcrec;
@@ -158,8 +163,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
crec = &xdf->recs[xdf->nrec++];
crec->ptr = prev;
crec->size = cur - prev;
- crec->line_hash = hav;
- if (xdl_classify_record(pass, cf, crec) < 0)
+ if (xdl_classify_record(pass, cf, crec, hav) < 0)
goto abort;
}
}
diff --git a/xdiff/xtypes.h b/xdiff/xtypes.h
index 979586f20a..50aee779be 100644
--- a/xdiff/xtypes.h
+++ b/xdiff/xtypes.h
@@ -41,7 +41,6 @@ typedef struct s_chastore {
typedef struct s_xrecord {
uint8_t const *ptr;
size_t size;
- uint64_t line_hash;
size_t minimal_perfect_hash;
} xrecord_t;