Skip to content

Commit 380ecb0

Browse files
committed
merge-ort: preserve cached renames for the appropriate side
Previous commits created an in-memory cache of the results of rename detection, and added logic to detect when that cache could appropriately be used in a subsequent merge operation -- but we were still unconditionally clearing the cache with each new merge operation anyway. If it is valid to reuse the cache from one of the two sides of history, preserve that side. Signed-off-by: Elijah Newren <[email protected]>
1 parent a50e295 commit 380ecb0

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

merge-ort.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,18 @@ static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
461461
/* Free memory used by various renames maps */
462462
for (i = MERGE_SIDE1; i <= MERGE_SIDE2; ++i) {
463463
strintmap_func(&renames->dirs_removed[i]);
464-
465-
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
466-
if (!reinitialize)
467-
strmap_clear(&renames->dir_rename_count[i], 1);
468-
469464
strmap_func(&renames->dir_renames[i], 0);
470-
471465
strintmap_func(&renames->relevant_sources[i]);
472-
strset_func(&renames->cached_target_names[i]);
473-
strmap_func(&renames->cached_pairs[i], 1);
474-
strset_func(&renames->cached_irrelevant[i]);
466+
if (!reinitialize)
467+
assert(renames->cached_pairs_valid_side == 0);
468+
if (i != renames->cached_pairs_valid_side) {
469+
strset_func(&renames->cached_target_names[i]);
470+
strmap_func(&renames->cached_pairs[i], 1);
471+
strset_func(&renames->cached_irrelevant[i]);
472+
partial_clear_dir_rename_count(&renames->dir_rename_count[i]);
473+
if (!reinitialize)
474+
strmap_clear(&renames->dir_rename_count[i], 1);
475+
}
475476
}
476477
renames->cached_pairs_valid_side = 0;
477478
renames->dir_rename_mask = 0;

0 commit comments

Comments
 (0)