Skip to content

Commit 333899e

Browse files
newrengitster
authored andcommitted
diffcore-rename: limit dir_rename_counts computation to relevant dirs
We are using dir_rename_counts to count the number of other directories that files within a directory moved to. We only need this information for directories that disappeared, though, so we can return early from update_dir_rename_counts() for other paths. If dirs_removed is passed to diffcore_rename_extended(), then it provides the relevant bits of information for us to limit this counting to relevant dirs. If dirs_removed is not passed, we would need to compute some replacement in order to do this limiting. Introduce a new info->relevant_source_dirs variable for this purpose, even though at this stage we will only set it to dirs_removed for simplicity. Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1ad69eb commit 333899e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

diffcore-rename.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ struct dir_rename_info {
371371
struct strintmap idx_map;
372372
struct strmap dir_rename_guess;
373373
struct strmap *dir_rename_count;
374+
struct strset *relevant_source_dirs;
374375
unsigned setup;
375376
};
376377

@@ -442,7 +443,13 @@ static void update_dir_rename_counts(struct dir_rename_info *info,
442443
return;
443444

444445
while (1) {
446+
/* Get old_dir, skip if its directory isn't relevant. */
445447
dirname_munge(old_dir);
448+
if (info->relevant_source_dirs &&
449+
!strset_contains(info->relevant_source_dirs, old_dir))
450+
break;
451+
452+
/* Get new_dir */
446453
dirname_munge(new_dir);
447454

448455
/*
@@ -521,6 +528,9 @@ static void initialize_dir_rename_info(struct dir_rename_info *info,
521528
strintmap_init_with_options(&info->idx_map, -1, NULL, 0);
522529
strmap_init_with_options(&info->dir_rename_guess, NULL, 0);
523530

531+
/* Setup info->relevant_source_dirs */
532+
info->relevant_source_dirs = dirs_removed;
533+
524534
/*
525535
* Loop setting up both info->idx_map, and doing setup of
526536
* info->dir_rename_count.

0 commit comments

Comments
 (0)