mirror of
https://github.com/git/git.git
synced 2026-03-07 15:57:43 +01:00
Merge branch 'pw/xdiff-classify-record-in-histogram' into next
"diff --histogram" optimization. * pw/xdiff-classify-record-in-histogram: xdiff: simplify comparison xdiff: avoid unnecessary memory allocations diff histogram: intern strings
This commit is contained in:
@@ -392,10 +392,7 @@ static xdchange_t *xdl_add_change(xdchange_t *xscr, long i1, long i2, long chg1,
|
||||
|
||||
static int recs_match(xrecord_t *rec1, xrecord_t *rec2, long flags)
|
||||
{
|
||||
return (rec1->ha == rec2->ha &&
|
||||
xdl_recmatch(rec1->ptr, rec1->size,
|
||||
rec2->ptr, rec2->size,
|
||||
flags));
|
||||
return (rec1->ha == rec2->ha);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -91,9 +91,8 @@ struct region {
|
||||
static int cmp_recs(xpparam_t const *xpp,
|
||||
xrecord_t *r1, xrecord_t *r2)
|
||||
{
|
||||
return r1->ha == r2->ha &&
|
||||
xdl_recmatch(r1->ptr, r1->size, r2->ptr, r2->size,
|
||||
xpp->flags);
|
||||
return r1->ha == r2->ha;
|
||||
|
||||
}
|
||||
|
||||
#define CMP_ENV(xpp, env, s1, l1, s2, l2) \
|
||||
|
||||
@@ -181,15 +181,11 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
||||
if (!(recs = (xrecord_t **) xdl_malloc(narec * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
|
||||
if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
|
||||
hbits = hsize = 0;
|
||||
else {
|
||||
hbits = xdl_hashbits((unsigned int) narec);
|
||||
hsize = 1 << hbits;
|
||||
if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
memset(rhash, 0, hsize * sizeof(xrecord_t *));
|
||||
}
|
||||
hbits = xdl_hashbits((unsigned int) narec);
|
||||
hsize = 1 << hbits;
|
||||
if (!(rhash = (xrecord_t **) xdl_malloc(hsize * sizeof(xrecord_t *))))
|
||||
goto abort;
|
||||
memset(rhash, 0, hsize * sizeof(xrecord_t *));
|
||||
|
||||
nrec = 0;
|
||||
if ((cur = blk = xdl_mmfile_first(mf, &bsize)) != NULL) {
|
||||
@@ -208,9 +204,7 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
||||
crec->size = (long) (cur - prev);
|
||||
crec->ha = hav;
|
||||
recs[nrec++] = crec;
|
||||
|
||||
if ((XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
|
||||
xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
|
||||
if (xdl_classify_record(pass, cf, rhash, hbits, crec) < 0)
|
||||
goto abort;
|
||||
}
|
||||
}
|
||||
@@ -219,10 +213,13 @@ static int xdl_prepare_ctx(unsigned int pass, mmfile_t *mf, long narec, xpparam_
|
||||
goto abort;
|
||||
memset(rchg, 0, (nrec + 2) * sizeof(char));
|
||||
|
||||
if (!(rindex = (long *) xdl_malloc((nrec + 1) * sizeof(long))))
|
||||
goto abort;
|
||||
if (!(ha = (unsigned long *) xdl_malloc((nrec + 1) * sizeof(unsigned long))))
|
||||
goto abort;
|
||||
if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
|
||||
(XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)) {
|
||||
if (!(rindex = xdl_malloc((nrec + 1) * sizeof(*rindex))))
|
||||
goto abort;
|
||||
if (!(ha = xdl_malloc((nrec + 1) * sizeof(*ha))))
|
||||
goto abort;
|
||||
}
|
||||
|
||||
xdf->nrec = nrec;
|
||||
xdf->recs = recs;
|
||||
@@ -279,8 +276,7 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
enl1 = xdl_guess_lines(mf1, sample) + 1;
|
||||
enl2 = xdl_guess_lines(mf2, sample) + 1;
|
||||
|
||||
if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF &&
|
||||
xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
|
||||
if (xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
|
||||
return -1;
|
||||
|
||||
if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {
|
||||
@@ -305,8 +301,7 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)
|
||||
xdl_free_classifier(&cf);
|
||||
xdl_free_classifier(&cf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user