Re: [[PATCH v2] 1/4] patch-ids: stop using a hand-rolled hashmap implementation
- From
- Eric Wong <e@80x24.org>
- Date
- Aug 1, 2016, 22:34 UTC
- Message-ID
- <20160801223447.GA10924@whir>
- In-Reply-To
- <xmqqy44gi7bp.fsf@gitster.mtv.corp.google.com>
Junio C Hamano <gitster@pobox.com> wrote:
Show 7 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes: > > > It would be a serious bug if hashmap_entry_init() played games with > > references, given its signature (that this function does not have any > > access to the hashmap structure, only to the entry itself): > > > > void hashmap_entry_init(void *entry, unsigned int hash)
<snip>
> I have a slight preference to avoid the lazy "void *", but that is > an unrelated tangent.
Me too. I noticed this while working on the http-walker speedups and my self-rejected last patch:
https://public-inbox.org/git/20160711210243.GA1604%40whir/
Extracting list_entry from list.h (currently in next[1]) and exposing that generically as "container_of" for use with hashmap_* would make it safer-to-use and allow structs to belong to multiple hashmaps.
list_entry is also an alias for container_of in the Linux kernel, but we don't have enough code using list_* to warrant two names for the same macro.
[1] https://public-inbox.org/git/20160711205131.1291-4-e%4080x24.org/