Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-29 Thread Jeff King
On Sat, Sep 29, 2018 at 11:31:08AM -0700, Junio C Hamano wrote: > > The only funny thing is that you have to "dereference" the iterator like > > this: > > > > struct list_head *pos; > > struct actual_thing *item; > > ... > > item = list_entry(pos, struct actual_thing, list_member); > > >

Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-29 Thread Junio C Hamano
Jeff King writes: > So yet another alternative here is to just define a single hashmap that > stores void pointers. That also throws away some type safety, but is > maybe conceptually simpler. I dunno. I was tempted to try that route, which would essentially give us "if you are abusing

Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-29 Thread Junio C Hamano
Jeff King writes: > On Wed, Sep 26, 2018 at 03:59:08PM -0700, Stefan Beller wrote: > >> > +struct refname_hash_entry { >> > + struct hashmap_entry ent; /* must be the first member */ >> >> $ git grep "struct hashmap_entry" reveals that we have another >> convention that we follow but not

Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-26 Thread Jeff King
On Wed, Sep 26, 2018 at 03:59:08PM -0700, Stefan Beller wrote: > > +struct refname_hash_entry { > > + struct hashmap_entry ent; /* must be the first member */ > > $ git grep "struct hashmap_entry" reveals that we have another > convention that we follow but not document, which is to stress

Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-26 Thread Jeff King
On Wed, Sep 26, 2018 at 02:28:28PM -0700, Junio C Hamano wrote: > In find_non_local_tags() helper function (used to implement the > "follow tags"), we use string_list_has_string() on two string lists > as a way to see if a refname has already been processed, etc. > > All this code predates more

Re: [PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-26 Thread Stefan Beller
On Wed, Sep 26, 2018 at 2:28 PM Junio C Hamano wrote: > > +struct refname_hash_entry { > + struct hashmap_entry ent; /* must be the first member */ $ git grep "struct hashmap_entry" reveals that we have another convention that we follow but not document, which is to stress the importance

[PATCH] fetch: replace string-list used as a look-up table with a hashmap

2018-09-26 Thread Junio C Hamano
In find_non_local_tags() helper function (used to implement the "follow tags"), we use string_list_has_string() on two string lists as a way to see if a refname has already been processed, etc. All this code predates more modern in-core lookup API like hashmap; replace them with two hashmaps and