@matheusbsbs / matheus-bagliano / commits / 4fb40c2b82
Fork 0

ll-merge: simplify opts == NULL case

As long as sizeof(struct ll_merge_options) is small, there is not much reason not to keep a copy of the default merge options in the BSS section. In return, we get clearer code and one less stack frame in the opts == NULL case. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Jan 15, 2011 at 19:08 UTC 4fb40c2b8206f7bdffedd8d58d2f9c031227b01b
1 file changed +3 -6
ll-merge.c
+3 -6
@@ -351,16 +351,13 @@ int ll_merge(mmbuffer_t *result_buf,
351 const struct ll_merge_options *opts)
352 {
353 static struct git_attr_check check[2];
354 + static const struct ll_merge_options default_opts;
355 const char *ll_driver_name = NULL;
356 int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
357 const struct ll_merge_driver *driver;
358
358 - if (!opts) {
359 - struct ll_merge_options default_opts = {0};
360 - return ll_merge(result_buf, path, ancestor, ancestor_label,
361 - ours, our_label, theirs, their_label,
362 - &default_opts);
363 - }
359 + if (!opts)
360 + opts = &default_opts;
361
362 if (opts->renormalize) {
363 normalize_file(ancestor, path);