From: Junio C Hamano <gitster@pobox•com>
To: "Dmitry S. Dolzhenko" <dmitrys.dolzhenko@yandex•ru>
Cc: git@vger•kernel.org
Subject: Re: [PATCH v4 05/14] diff.c: use ALLOC_GROW()
Date: Mon, 03 Mar 2014 14:48:33 -0800 [thread overview]
Message-ID: <xmqq1tyioq4e.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1393885922-21616-6-git-send-email-dmitrys.dolzhenko@yandex.ru> (Dmitry S. Dolzhenko's message of "Tue, 4 Mar 2014 02:31:53 +0400")
"Dmitry S. Dolzhenko" <dmitrys.dolzhenko@yandex•ru> writes:
> Use ALLOC_GROW() instead inline code in
> diffstat_add() and diff_q()
"...instead of open coding it in..." may read better.
>
> Signed-off-by: Dmitry S. Dolzhenko <dmitrys.dolzhenko@yandex•ru>
> ---
> diff.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/diff.c b/diff.c
> index e800666..aebdfda 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -1361,11 +1361,7 @@ static struct diffstat_file *diffstat_add(struct diffstat_t *diffstat,
> {
> struct diffstat_file *x;
> x = xcalloc(sizeof (*x), 1);
> - if (diffstat->nr == diffstat->alloc) {
> - diffstat->alloc = alloc_nr(diffstat->alloc);
> - diffstat->files = xrealloc(diffstat->files,
> - diffstat->alloc * sizeof(x));
> - }
> + ALLOC_GROW(diffstat->files, diffstat->nr + 1, diffstat->alloc);
> diffstat->files[diffstat->nr++] = x;
> if (name_b) {
> x->from_name = xstrdup(name_a);
> @@ -3965,11 +3961,7 @@ struct diff_queue_struct diff_queued_diff;
>
> void diff_q(struct diff_queue_struct *queue, struct diff_filepair *dp)
> {
> - if (queue->alloc <= queue->nr) {
> - queue->alloc = alloc_nr(queue->alloc);
> - queue->queue = xrealloc(queue->queue,
> - sizeof(dp) * queue->alloc);
> - }
> + ALLOC_GROW(queue->queue, queue->nr + 1, queue->alloc);
> queue->queue[queue->nr++] = dp;
> }
next prev parent reply other threads:[~2014-03-03 22:48 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-03 22:31 [PATCH v4 00/14] Use ALLOC_GROW() instead of inline code Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 01/14] builtin/pack-objects.c: use ALLOC_GROW() in check_pbase_path() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 02/14] bundle.c: use ALLOC_GROW() in add_to_ref_list() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 03/14] cache-tree.c: use ALLOC_GROW() in find_subtree() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 04/14] commit.c: use ALLOC_GROW() in register_commit_graft() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 05/14] diff.c: use ALLOC_GROW() Dmitry S. Dolzhenko
2014-03-03 22:48 ` Junio C Hamano [this message]
2014-03-03 22:31 ` [PATCH v4 06/14] diffcore-rename.c: " Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 07/14] patch-ids.c: use ALLOC_GROW() in add_commit() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 08/14] replace_object.c: use ALLOC_GROW() in register_replace_object() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 09/14] reflog-walk.c: use ALLOC_GROW() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 10/14] dir.c: use ALLOC_GROW() in create_simplify() Dmitry S. Dolzhenko
2014-03-03 22:31 ` [PATCH v4 11/14] attr.c: use ALLOC_GROW() in handle_attr_line() Dmitry S. Dolzhenko
2014-03-03 22:32 ` [PATCH v4 12/14] builtin/mktree.c: use ALLOC_GROW() in append_to_tree() Dmitry S. Dolzhenko
2014-03-03 22:32 ` [PATCH v4 13/14] read-cache.c: use ALLOC_GROW() in add_index_entry() Dmitry S. Dolzhenko
2014-03-03 22:32 ` [PATCH v4 14/14] sha1_file.c: use ALLOC_GROW() in pretend_sha1_file() Dmitry S. Dolzhenko
2014-03-03 23:02 ` [PATCH v4 00/14] Use ALLOC_GROW() instead of inline code Junio C Hamano
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=xmqq1tyioq4e.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=dmitrys.dolzhenko@yandex$(echo .)ru \
--cc=git@vger$(echo .)kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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