summaryrefslogtreecommitdiff
path: root/diffcore-rename.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2021-02-27 00:30:47 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-02-27 01:53:12 (GMT)
commit333899e1e3f15010a85588e67a4ef0f664966c44 (patch)
treea754525c05b4f7ae8461923220070230c94b8c91 /diffcore-rename.c
parent1ad69eb0dcfa61e175e7540517bd4e6e7a66822a (diff)
downloadgit-333899e1e3f15010a85588e67a4ef0f664966c44.zip
git-333899e1e3f15010a85588e67a4ef0f664966c44.tar.gz
git-333899e1e3f15010a85588e67a4ef0f664966c44.tar.bz2
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 <dstolee@microsoft.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diffcore-rename.c')
-rw-r--r--diffcore-rename.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/diffcore-rename.c b/diffcore-rename.c
index 10f8f4a..e5fa0cb 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -371,6 +371,7 @@ struct dir_rename_info {
struct strintmap idx_map;
struct strmap dir_rename_guess;
struct strmap *dir_rename_count;
+ struct strset *relevant_source_dirs;
unsigned setup;
};
@@ -442,7 +443,13 @@ static void update_dir_rename_counts(struct dir_rename_info *info,
return;
while (1) {
+ /* Get old_dir, skip if its directory isn't relevant. */
dirname_munge(old_dir);
+ if (info->relevant_source_dirs &&
+ !strset_contains(info->relevant_source_dirs, old_dir))
+ break;
+
+ /* Get new_dir */
dirname_munge(new_dir);
/*
@@ -521,6 +528,9 @@ static void initialize_dir_rename_info(struct dir_rename_info *info,
strintmap_init_with_options(&info->idx_map, -1, NULL, 0);
strmap_init_with_options(&info->dir_rename_guess, NULL, 0);
+ /* Setup info->relevant_source_dirs */
+ info->relevant_source_dirs = dirs_removed;
+
/*
* Loop setting up both info->idx_map, and doing setup of
* info->dir_rename_count.