From: Karsten Blees <karsten.blees@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH/RFC 1/5] add a hashtable implementation that supports O(1) removal
Date: Mon, 23 Sep 2013 11:21:57 +0200 [thread overview]
Message-ID: <52400835.8090902@gmail.com> (raw)
In-Reply-To: <xmqqmwnir86z.fsf@gitster.dls.corp.google.com>
Am 12.09.2013 06:10, schrieb Junio C Hamano:
> Karsten Blees <karsten.blees@gmail.com> writes:
>
>> +/*
>> + * Hashmap entry data structure, intended to be used as first member of user
>> + * data structures. Consists of a pointer and an int. Ideally it should be
>
> It is technically correct to say this is "intended to be" used, but
> to those who are using this API, it would be more helpful to say "a
> user data structure that uses this API *must* have this as its first
> member field".
>
Right. I considered making the position in the user struct configurable via some offsetof() magic, but this would have just complicated things unnecessarily.
>> + * followed by an int-sized member to prevent unused memory on 64-bit systems
>> + * due to alignment.
>> + */
>> +typedef struct hashmap_entry {
>> + struct hashmap_entry *next;
>> + unsigned int hash;
>> +} hashmap_entry;
>> + ...
>> +typedef struct hashmap {
>> + hashmap_entry **table;
>> + hashmap_cmp_fn cmpfn;
>> + unsigned int size, tablesize;
>> +} hashmap;
>
> I forgot to mention in my previous message, but we find that the
> code tends to be easier to read if we avoid using typedef'ed struct
> like these. E.g. in 2/5 we see something like this:
>
> static int abbrev = -1; /* unspecified */
> static int max_candidates = 10;
> -static struct hash_table names;
> +static hashmap names;
> static int have_util;
> static const char *pattern;
> static int always;
> @@ -38,7 +38,7 @@ static const char *diff_index_args[] = {
>
>
> struct commit_name {
> - struct commit_name *next;
> + hashmap_entry entry;
> unsigned char peeled[20];
>
> The version before the patch is preferrable.
>
OK
next prev parent reply other threads:[~2013-09-23 9:22 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-10 23:27 [PATCH/RFC 0/5] New hash table implementation Karsten Blees
2013-09-10 23:28 ` [PATCH/RFC 1/5] add a hashtable implementation that supports O(1) removal Karsten Blees
2013-09-11 23:56 ` Junio C Hamano
2013-09-23 9:16 ` Karsten Blees
2013-09-12 4:10 ` Junio C Hamano
2013-09-23 9:21 ` Karsten Blees [this message]
2013-09-10 23:28 ` [PATCH/RFC 2/5] buitin/describe.c: use new hash map implementation Karsten Blees
2013-09-10 23:29 ` [PATCH/RFC 3/5] diffcore-rename.c: move code around to prepare for the next patch Karsten Blees
2013-09-10 23:30 ` [PATCH/RFC 4/5] diffcore-rename.c: simplify finding exact renames Karsten Blees
2013-09-10 23:30 ` [PATCH/RFC 5/5] diffcore-rename.c: use new hash map implementation Karsten Blees
2013-09-24 9:50 ` [PATCH v2 0/5] New hash table implementation Karsten Blees
2013-09-24 9:51 ` [PATCH v2 1/5] add a hashtable implementation that supports O(1) removal Karsten Blees
2013-09-24 9:52 ` [PATCH v2 2/5] buitin/describe.c: use new hash map implementation Karsten Blees
2013-09-24 9:52 ` [PATCH v2 3/5] diffcore-rename.c: move code around to prepare for the next patch Karsten Blees
2013-09-24 9:53 ` [PATCH v2 4/5] diffcore-rename.c: simplify finding exact renames Karsten Blees
2013-09-24 9:54 ` [PATCH v2 5/5] diffcore-rename.c: use new hash map implementation Karsten Blees
2013-09-24 10:18 ` [PATCH v2 0/5] New hash table implementation Fredrik Gustafsson
2013-09-24 11:16 ` Tay Ray Chuan
2013-09-26 14:38 ` Karsten Blees
2013-09-26 10:16 ` Fredrik Gustafsson
2013-09-26 10:26 ` Duy Nguyen
2013-09-26 11:08 ` Fredrik Gustafsson
2013-09-26 11:14 ` Duy Nguyen
2013-09-26 13:55 ` Karsten Blees
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=52400835.8090902@gmail.com \
--to=karsten.blees@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 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).