git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Timo Hirvonen <tihirvon@gmail.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, junkio@cox.net
Subject: Re: [PATCH] Make git-fmt-merge-msg a builtin
Date: Mon, 3 Jul 2006 17:17:51 +0300	[thread overview]
Message-ID: <20060703171751.2ed33220.tihirvon@gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.63.0607031530380.29667@wbgn013.biozentrum.uni-wuerzburg.de>

Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:

> +struct list {
> +	char **list;
> +	void **payload;
> +	unsigned nr, alloc;
> +};

How about something like this instead to reduce mallocs to half and
simplify the code?

struct item {
	char *value;
	void *payload;
};

struct list {
	struct item *items;
	unsigned int nr, alloc;
};

(But I realize this isn't performance critical)

> +static void append_to_list(struct list *list, char *value)

Add void *payload parameter too, would simplify the code.

> +static void free_list(struct list *list)
> +{
> +	int i;
> +
> +	if (list->alloc == 0)
> +		return;

Unnecessary if nr is 0 too.

> +	for (i = 0; i < list->nr; i++) {
> +		free(list->list[i]);
> +		if (list->payload[i])
> +			free(list->payload[i]);

free(NULL) is safe.

> +	}
> +	free(list->list);
> +	free(list->payload);
> +	list->nr = list->alloc = 0;
> +}

> +	if (!strncmp(line, "branch ", 7)) {
> +		origin = strdup(line + 7);
> +		append_to_list(&(src_data->branch), origin);

Parenthesis isn't needed.

> +	head->object.flags |= UNINTERESTING;
> +        prepare_revision_walk(rev);

Spaces..

> +	if (merge_summary) {
> +		struct commit *head;
> +		struct rev_info rev;
> +
> +		head = lookup_commit(head_sha1);
> +parse_object(head->object.sha1);
> +head = head->parents->item;

Indentation.

-- 
http://onion.dynserv.net/~timo/

  reply	other threads:[~2006-07-03 14:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-03 13:31 [PATCH] Make git-fmt-merge-msg a builtin Johannes Schindelin
2006-07-03 14:17 ` Timo Hirvonen [this message]
2006-07-03 14:36   ` Johannes Schindelin
2006-07-03 15:26     ` Timo Hirvonen
2006-07-03 15:45       ` Johannes Schindelin
2006-07-03 16:16         ` Timo Hirvonen
2006-07-03 21:29           ` Johannes Schindelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060703171751.2ed33220.tihirvon@gmail.com \
    --to=tihirvon@gmail.com \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).