summaryrefslogtreecommitdiff
path: root/merge-ort.c
diff options
context:
space:
mode:
authorElijah Newren <newren@gmail.com>2020-12-16 22:28:01 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-12-17 05:56:39 (GMT)
commit43e9c4eeccc069dbe6ca8a65dc5d0093b46acc03 (patch)
tree6bc2f73f50f8858d2db01a3f49834a21e5e3914f /merge-ort.c
parent4296d8f17d45465c9712fab099a1a6787a8e9913 (diff)
downloadgit-43e9c4eeccc069dbe6ca8a65dc5d0093b46acc03.zip
git-43e9c4eeccc069dbe6ca8a65dc5d0093b46acc03.tar.gz
git-43e9c4eeccc069dbe6ca8a65dc5d0093b46acc03.tar.bz2
merge-ort: make clear_internal_opts() aware of partial clearing
In order to handle recursive merges, after merging merge-bases we need to clear away most of the data we had built up but some of it needs to be kept -- in particular the "output" field. Rename the function to reflect its future change in use. Further, since "reinitialize" means we'll be reusing the fields immediately, take advantage of this to only partially clear maps, leaving the hashtable allocated and pre-sized. (This may be slightly out-of-order since the speedups aren't realized until there are far more strmaps in use, but the patch submission process already went out of order because of various questions and requests for strmap. Anyway, see commit 6ccdfc2a20 ("strmap: enable faster clearing and reusing of strmaps", 2020-11-05), for performance details about the use of strmap_partial_clear().) Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-ort.c')
-rw-r--r--merge-ort.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/merge-ort.c b/merge-ort.c
index 6eac0ce..bd237f3 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -253,10 +253,11 @@ static void free_strmap_strings(struct strmap *map)
}
}
-static void clear_internal_opts(struct merge_options_internal *opti,
- int reinitialize)
+static void clear_or_reinit_internal_opts(struct merge_options_internal *opti,
+ int reinitialize)
{
- assert(!reinitialize);
+ void (*strmap_func)(struct strmap *, int) =
+ reinitialize ? strmap_partial_clear : strmap_clear;
/*
* We marked opti->paths with strdup_strings = 0, so that we
@@ -266,14 +267,14 @@ static void clear_internal_opts(struct merge_options_internal *opti,
* to deallocate them.
*/
free_strmap_strings(&opti->paths);
- strmap_clear(&opti->paths, 1);
+ strmap_func(&opti->paths, 1);
/*
* All keys and values in opti->conflicted are a subset of those in
* opti->paths. We don't want to deallocate anything twice, so we
* don't free the keys and we pass 0 for free_values.
*/
- strmap_clear(&opti->conflicted, 0);
+ strmap_func(&opti->conflicted, 0);
/*
* opti->paths_to_free is similar to opti->paths; we created it with
@@ -1344,7 +1345,7 @@ void merge_finalize(struct merge_options *opt,
assert(opt->priv == NULL);
- clear_internal_opts(opti, 0);
+ clear_or_reinit_internal_opts(opti, 0);
FREE_AND_NULL(opti);
}