Re: [PATCH v3 2/3] config: add hashtable for config parsing & retrieval

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH v3 2/3] config: add hashtable for config parsing & retrieval

From: Junio C Hamano <hidden>
Date: 2016-06-15 23:01:45

Karsten Blees [off-list ref] writes:
quoted
Because I had an experience under my belt of a painful refactoring
of "the_index" which turned out to be not just a single array, I
simply suspect that the final data structure to represent a "set of
config-like things" will not be just a single hashmap, hence I do
prefer to have one layer of abstraction "struct config_set", which
would contain a hashmap and possibly more.  Doesn't "is the hashmap
initialized" bit belong there, for example?
Would an additional

  int hashmap_is_initialized(constr struct hashmap *map)
  {
    return !!map->table;
  }

API help? (Note that hashmap_free() already does memset(0), so the
usual notion of "zero memory means unitialized" applies).
It may remove the need for the separate "hashmap_initialized" bit
that was implemented as a file-scope global in the patch.

I however am not convinced that it will be the _only_ thing other
than the hashmap we would need to use to keep track of the in-core
"set of config-like things", and usually a blanket statement "these
are the only thing we would ever need" tends not to hold for long,
so...

Re: [PATCH v3 2/3] config: add hashtable for config parsing & retrieval

From: Karsten Blees <hidden>
Date: 2016-06-15 23:01:45

Am 26.06.2014 23:21, schrieb Junio C Hamano:
Karsten Blees [off-list ref] writes:
quoted
quoted
Because I had an experience under my belt of a painful refactoring
of "the_index" which turned out to be not just a single array, I
simply suspect that the final data structure to represent a "set of
config-like things" will not be just a single hashmap, hence I do
prefer to have one layer of abstraction "struct config_set", which
would contain a hashmap and possibly more.  Doesn't "is the hashmap
initialized" bit belong there, for example?
Would an additional

  int hashmap_is_initialized(constr struct hashmap *map)
  {
    return !!map->table;
  }

API help? (Note that hashmap_free() already does memset(0), so the
usual notion of "zero memory means unitialized" applies).
It may remove the need for the separate "hashmap_initialized" bit
that was implemented as a file-scope global in the patch.
That the variable is redundant was all I was trying to say, sorry for
the misunderstanding. But reading through api-hashmap.txt again, I
found that documentation of the hashmap members is pretty vague, so
perhaps improving the docs would suffice (e.g. "hashmap.table != NULL
indicates the hashmap has been initialized.").
I however am not convinced that it will be the _only_ thing other
than the hashmap we would need to use to keep track of the in-core
"set of config-like things", and usually a blanket statement "these
are the only thing we would ever need" tends not to hold for long,
so...
I think having an extra type for the configuration is a Good Thing
(even if the only member is a hashmap). Although I wouldn't call it
'config_set', as it conflicts with the verb 'set', resulting in
weird APIs ('config_set_get_value()', 'config_set_set_value()').
Perhaps 'config_map' or 'config_settings', or just 'config'?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help