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>

Stefan Beller committed Jul 19, 2018 at 11:56 UTC 282098506ffb42d151a3c8d324b6b5393a4342a4
1 file changed +11 -11
xdiff/xhistogram.c
+11 -11
@@ -233,6 +233,16 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
233 return b_next;
234 }
235
236 +static int fall_back_to_classic_diff(xpparam_t const *xpp, xdfenv_t *env,
237 + int line1, int count1, int line2, int count2)
238 +{
239 + xpparam_t xpparam;
240 + xpparam.flags = xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
241 +
242 + return xdl_fall_back_diff(env, &xpparam,
243 + line1, count1, line2, count2);
244 +}
245 +
246 static int find_lcs(struct histindex *index, struct region *lcs,
247 int line1, int count1, int line2, int count2) {
248 int b_ptr;
@@ -248,16 +258,6 @@ static int find_lcs(struct histindex *index, struct region *lcs,
258 return index->has_common && index->max_chain_length < index->cnt;
259 }
260
251 -static int fall_back_to_classic_diff(struct histindex *index,
252 - int line1, int count1, int line2, int count2)
253 -{
254 - xpparam_t xpp;
255 - xpp.flags = index->xpp->flags & ~XDF_DIFF_ALGORITHM_MASK;
256 -
257 - return xdl_fall_back_diff(index->env, &xpp,
258 - line1, count1, line2, count2);
259 -}
260 -
261 static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
262 int line1, int count1, int line2, int count2)
263 {
@@ -320,7 +320,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
320
321 memset(&lcs, 0, sizeof(lcs));
322 if (find_lcs(&index, &lcs, line1, count1, line2, count2))
323 - result = fall_back_to_classic_diff(&index, line1, count1, line2, count2);
323 + result = fall_back_to_classic_diff(xpp, env, line1, count1, line2, count2);
324 else {
325 if (lcs.begin1 == 0 && lcs.begin2 == 0) {
326 while (count1--)