Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-10 Thread Michael Haggerty
On 02/09/2017 09:34 PM, Junio C Hamano wrote: > Michael Haggerty writes: >> [...] >> +static int submodule_hash_cmp(const void *entry, const void *entry_or_key, >> + const void *keydata) >> +{ >> +const struct submodule_hash_entry *e1 = entry, *e2 = entry_or_key; >> +

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Jeff King
On Thu, Feb 09, 2017 at 12:34:04PM -0800, Junio C Hamano wrote: > > +static struct submodule_hash_entry *alloc_submodule_hash_entry( > > + const char *submodule, struct ref_store *refs) > > +{ > > + size_t len = strlen(submodule); > > + struct submodule_hash_entry *entry = malloc(siz

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Junio C Hamano
Michael Haggerty writes: > Aside from scaling better, this means that the submodule name needn't be > stored in the ref_store instance anymore (which will be changed in a > moment). Nice. I like the latter reason very much (this is not a suggestion to change the description). > +struct submodu

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Jeff King
On Thu, Feb 09, 2017 at 06:40:29PM +0100, Michael Haggerty wrote: > On 02/09/2017 05:58 PM, Stefan Beller wrote: > >> @@ -1402,17 +1435,17 @@ struct ref_store *ref_store_init(const char > >> *submodule) > >> > >> struct ref_store *lookup_ref_store(const char *submodule) > >> { > > > >> +

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Stefan Beller
On Thu, Feb 9, 2017 at 9:40 AM, Michael Haggerty wrote: > On 02/09/2017 05:58 PM, Stefan Beller wrote: >>> @@ -1402,17 +1435,17 @@ struct ref_store *ref_store_init(const char >>> *submodule) >>> >>> struct ref_store *lookup_ref_store(const char *submodule) >>> { >> >>> + if (!submodule_re

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Michael Haggerty
On 02/09/2017 05:58 PM, Stefan Beller wrote: >> @@ -1402,17 +1435,17 @@ struct ref_store *ref_store_init(const char >> *submodule) >> >> struct ref_store *lookup_ref_store(const char *submodule) >> { > >> + if (!submodule_ref_stores.tablesize) >> + hashmap_init(&submodule_re

Re: [PATCH 1/5] refs: store submodule ref stores in a hashmap

2017-02-09 Thread Stefan Beller
> @@ -1402,17 +1435,17 @@ struct ref_store *ref_store_init(const char > *submodule) > > struct ref_store *lookup_ref_store(const char *submodule) > { > + if (!submodule_ref_stores.tablesize) > + hashmap_init(&submodule_ref_stores, submodule_hash_cmp, 20); So we can lookup