Skip to content

Commit

Permalink
diffcore-rename: rename num_create to num_destinations
Browse files Browse the repository at this point in the history
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@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
newren authored and gitster committed Dec 14, 2020
1 parent 3a0b884 commit 26a66a6
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions diffcore-rename.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 26a66a6

Please sign in to comment.