xdiff/xhistogram: pass arguments directly to fall_back_to_classic_diff
By passing the 'xpp' and 'env' argument directly to the function 'fall_back_to_classic_diff', we eliminate an occurrence of the 'index' in histogram_diff, which will prove useful in a bit. While at it, move it up in the file. This will make the diff of one of the next patches more legible. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
27dea4683b
commit
282098506f
@ -233,6 +233,16 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
|
|||||||
return b_next;
|
return b_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
|
||||||
|
int line1, int count1, int line2, int count2)
|
||||||
|
{
|
||||||
|
xpparam_t xpparam;
|
||||||
|
xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
|
||||||
|
|
||||||
|
return xdl_fall_back_diff(env, &xpparam,
|
||||||
|
line1, count1, line2, count2);
|
||||||
|
}
|
||||||
|
|
||||||
static int find_lcs(struct histindex *index, struct region *lcs,
|
static int find_lcs(struct histindex *index, struct region *lcs,
|
||||||
int line1, int count1, int line2, int count2) {
|
int line1, int count1, int line2, int count2) {
|
||||||
int b_ptr;
|
int b_ptr;
|
||||||
@ -248,16 +258,6 @@ static int find_lcs(struct histindex *index, struct region *lcs,
|
|||||||
return index->has_common && index->max_chain_length < index->cnt;
|
return index->has_common && index->max_chain_length < index->cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fall_back_to_classic_diff(struct histindex *index,
|
|
||||||
int line1, int count1, int line2, int count2)
|
|
||||||
{
|
|
||||||
xpparam_t xpp;
|
|
||||||
xpp.flags = index->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
|
|
||||||
|
|
||||||
return xdl_fall_back_diff(index->env, &xpp,
|
|
||||||
line1, count1, line2, count2);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
|
static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
|
||||||
int line1, int count1, int line2, int count2)
|
int line1, int count1, int line2, int count2)
|
||||||
{
|
{
|
||||||
@ -320,7 +320,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
|
|||||||
|
|
||||||
memset(&lcs, 0, sizeof(lcs));
|
memset(&lcs, 0, sizeof(lcs));
|
||||||
if (find_lcs(&index, &lcs, line1, count1, line2, count2))
|
if (find_lcs(&index, &lcs, line1, count1, line2, count2))
|
||||||
result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
|
result = fall_back_to_classic_diff(xpp, env, line1, count1, line2, count2);
|
||||||
else {
|
else {
|
||||||
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
|
if (lcs.begin1 == 0 && lcs.begin2 == 0) {
|
||||||
while (count1--)
|
while (count1--)
|
||||||
|
Loading…
Reference in New Issue
Block a user