git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1.7.4-rc2] ll-merge: simplify opts == NULL case

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 16, 2011, 01:08 UTC
Message-ID
<20110116010841.GA18049@burratino>
In-Reply-To
<7vpqx5mipt.fsf@alter.siamese.dyndns.org>
Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
Show 7 quoted lines
>> +	if (!opts) {
>> +		struct ll_merge_options default_opts = {0};
>> +		return ll_merge(result_buf, path, ancestor, ancestor_label,
>> +				ours, our_label, theirs, their_label,
>> +				&default_opts);
>
> Fun---expecting tail recursion elimination ;-)?
Fun but not warranted.  Let's simplify.
-- 8< --
Subject: 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>
---
 ll-merge.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/ll-merge.c b/ll-merge.c
index 007dd3e..6ce512e 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -351,16 +351,13 @@ int ll_merge(mmbuffer_t *result_buf,
 	     const struct ll_merge_options *opts)
 {
 	static struct git_attr_check check[2];
+	static const struct ll_merge_options default_opts;
 	const char *ll_driver_name = NULL;
 	int marker_size = DEFAULT_CONFLICT_MARKER_SIZE;
 	const struct ll_merge_driver *driver;
 
-	if (!opts) {
-		struct ll_merge_options default_opts = {0};
-		return ll_merge(result_buf, path, ancestor, ancestor_label,
-				ours, our_label, theirs, their_label,
-				&default_opts);
-	}
+	if (!opts)
+		opts = &default_opts;
 
 	if (opts->renormalize) {
 		normalize_file(ancestor, path);
-- 
1.7.4.rc2
Previous: Junio C HamanoNext: Jonathan Nieder
Message 19 of 23 in “git-merge: ignore space support”
  1. git-merge: ignore space supportJustin Frankel, Aug 23, 2010
  2. Jonathan NiederAug 24, 2010
  3. merge-recursive: expose merge options for builtin mergeJonathan Nieder, Aug 24, 2010
  4. Junio C HamanoAug 24, 2010
  5. Jonathan NiederAug 25, 2010
  6. Justin FrankelAug 24, 2010
  7. Jonathan NiederAug 25, 2010
  8. Bert WesargAug 25, 2010
  9. Justin FrankelAug 25, 2010
  10. Junio C HamanoAug 25, 2010
  11. Justin FrankelAug 25, 2010
  12. Junio C HamanoAug 24, 2010
  13. Bert WesargAug 24, 2010
  14. Jonathan NiederAug 25, 2010
  15. 0/4 git-merge: ignore space supportJonathan Nieder, Aug 26, 2010
  16. 1/4 merge-recursive: expose merge options for builtin mergeJonathan Nieder, Aug 26, 2010
  17. 2/4 ll-merge: replace flag argument with options structJonathan Nieder, Aug 26, 2010
  18. Junio C HamanoAug 26, 2010
  19. ll-merge: simplify opts == NULL caseJonathan Nieder, Jan 16, 2011
  20. 3/4 merge-recursive --patienceJonathan Nieder, Aug 26, 2010
  21. 4/4 merge-recursive: options to ignore whitespace changesJonathan Nieder, Aug 26, 2010
  22. Junio C HamanoAug 26, 2010
  23. Jonathan NiederAug 27, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.