From: Elijah Newren <newren@xxxxxxxxx> Our main data structures are rename_src and rename_dst. For counters of these data structures, num_sources and num_destinations seem natural; definitely more so than using num_create for the latter. Signed-off-by: Elijah Newren <newren@xxxxxxxxx> --- diffcore-rename.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/diffcore-rename.c b/diffcore-rename.c index d367a6d2443..15a98f566e4 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -434,7 +434,7 @@ static void record_if_better(struct diff_score m[], struct diff_score *o) * 1 if we need to disable inexact rename detection; * 2 if we would be under the limit if we were given -C instead of -C -C. */ -static int too_many_rename_candidates(int num_create, +static int too_many_rename_candidates(int num_destinations, struct diff_options *options) { int rename_limit = options->rename_limit; @@ -447,17 +447,17 @@ static int too_many_rename_candidates(int num_create, * This basically does a test for the rename matrix not * growing larger than a "rename_limit" square matrix, ie: * - * num_create * num_src > rename_limit * rename_limit + * num_destinations * num_src > rename_limit * rename_limit */ if (rename_limit <= 0) rename_limit = 32767; - if ((num_create <= rename_limit || num_src <= rename_limit) && - ((uint64_t)num_create * (uint64_t)num_src + if ((num_destinations <= rename_limit || num_src <= rename_limit) && + ((uint64_t)num_destinations * (uint64_t)num_src <= (uint64_t)rename_limit * (uint64_t)rename_limit)) return 0; options->needed_rename_limit = - num_src > num_create ? num_src : num_create; + num_src > num_destinations ? num_src : num_destinations; /* Are we running under -C -C? */ if (!options->flags.find_copies_harder) @@ -469,8 +469,8 @@ static int too_many_rename_candidates(int num_create, continue; num_src++; } - if ((num_create <= rename_limit || num_src <= rename_limit) && - ((uint64_t)num_create * (uint64_t)num_src + if ((num_destinations <= rename_limit || num_src <= rename_limit) && + ((uint64_t)num_destinations * (uint64_t)num_src <= (uint64_t)rename_limit * (uint64_t)rename_limit)) return 2; return 1; @@ -505,7 +505,7 @@ void diffcore_rename(struct diff_options *options) struct diff_queue_struct outq; struct diff_score *mx; int i, j, rename_count, skip_unmodified = 0; - int num_create, dst_cnt; + int num_destinations, dst_cnt; struct progress *progress = NULL; if (!minimum_score) @@ -570,13 +570,13 @@ void diffcore_rename(struct diff_options *options) * Calculate how many renames are left (but all the source * files still remain as options for rename/copies!) */ - num_create = (rename_dst_nr - rename_count); + num_destinations = (rename_dst_nr - rename_count); /* All done? */ - if (!num_create) + if (!num_destinations) goto cleanup; - switch (too_many_rename_candidates(num_create, options)) { + switch (too_many_rename_candidates(num_destinations, options)) { case 1: goto cleanup; case 2: @@ -593,7 +593,8 @@ void diffcore_rename(struct diff_options *options) (uint64_t)rename_dst_nr * (uint64_t)rename_src_nr); } - mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_create), sizeof(*mx)); + mx = xcalloc(st_mult(NUM_CANDIDATE_PER_DST, num_destinations), + sizeof(*mx)); for (dst_cnt = i = 0; i < rename_dst_nr; i++) { struct diff_filespec *two = rename_dst[i].two; struct diff_score *m; -- gitgitgadget