From: Jakub Narebski <jnareb@gmail.com>
To: Stephen Boyd <bebarino@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] hash: Remove useless init_hash()
Date: Tue, 27 Jul 2010 03:30:00 -0700 (PDT) [thread overview]
Message-ID: <m3fwz5kykn.fsf@localhost.localdomain> (raw)
In-Reply-To: <1280208970-23394-1-git-send-email-bebarino@gmail.com>
Stephen Boyd <bebarino@gmail.com> writes:
> init_hash() is essentially a memset() so just use that.
>
> Signed-off-by: Stephen Boyd <bebarino@gmail.com>
[...]
Encapsulation is good.
> diff --git a/diffcore-rename.c b/diffcore-rename.c
> index df41be5..b355520 100644
> --- a/diffcore-rename.c
> +++ b/diffcore-rename.c
> @@ -382,7 +382,7 @@ static int find_exact_renames(void)
> int i;
> struct hash_table file_table;
>
> - init_hash(&file_table);
> + memset(&file_table, 0, sizeof(file_table));
This is IMHO slightly less readable, and doesn't protect against
changes in implementation.
> for (i = 0; i < rename_src_nr; i++)
> insert_file_table(&file_table, -1, i, rename_src[i].one);
>
> diff --git a/hash.h b/hash.h
> index 69e33a4..418be24 100644
> --- a/hash.h
> +++ b/hash.h
> @@ -33,11 +33,4 @@ extern void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table
> extern int for_each_hash(const struct hash_table *table, int (*fn)(void *));
> extern void free_hash(struct hash_table *table);
>
> -static inline void init_hash(struct hash_table *table)
> -{
> - table->size = 0;
> - table->nr = 0;
> - table->array = NULL;
> -}
*This* could be replaced by memset.
> -
> #endif
> --
> 1.7.2.19.g9a302
>
--
Jakub Narebski
Poland
ShadeHawk on #git
next prev parent reply other threads:[~2010-07-27 10:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-27 5:36 [PATCH] hash: Remove useless init_hash() Stephen Boyd
2010-07-27 10:30 ` Jakub Narebski [this message]
2010-07-27 10:36 ` Ævar Arnfjörð Bjarmason
2010-07-27 19:49 ` Jeff King
2010-07-27 19:58 ` Ævar Arnfjörð Bjarmason
2010-07-28 7:33 ` Stephen Boyd
2010-07-27 15:55 ` Linus Torvalds
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=m3fwz5kykn.fsf@localhost.localdomain \
--to=jnareb@gmail.com \
--cc=bebarino@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.