git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] oidmap: map with OID as key

From
BWBrandon Williams <bmwill@google.com>
Date
Sep 28, 2017, 00:41 UTC
Message-ID
<20170928004137.GD68699@google.com>
In-Reply-To
<20170927221910.164552-1-jonathantanmy@google.com>
On 09/27, Jonathan Tan wrote:
Show 6 quoted lines
> This is similar to using the hashmap in hashmap.c, but with an
> easier-to-use API. In particular, custom entry comparisons no longer
> need to be written, and lookups can be done without constructing a
> temporary entry structure.
> 
> oidset has been updated to use oidmap.

After a quick glance at the code, I think it looks good. I do have one suggestion though. This map is structured much like our internal hashmap where if you want to include any data you have to implement your own struct with the internal 'entry' struct as the first member in your custom struct. I personal dislike this method, despite the potential memory savings, because it makes the data structure much more difficult to use.

If all i wanted was a map from 'OID -> const char *' then I would need to write all the boilerplate code to make a struct which contains the map 'entry' struct + the 'const char *' entry. You are also making the caller responsible for allocating the individual entries instead of letting the data structure take care of that internally.

To me it seems like a much simpler API for a map would be to just allow callers to store a 'void *' as the value.

-- 
Brandon Williams
Previous: Jonathan TanNext: Jonathan Tan
Message 2 of 16 in “oidmap: map with OID as key”
  1. oidmap: map with OID as keyJonathan Tan, Sep 27, 2017
  2. Brandon WilliamsSep 28, 2017
  3. Jonathan TanSep 28, 2017
  4. Jeff KingSep 28, 2017
  5. Jonathan TanSep 29, 2017
  6. Jeff KingSep 29, 2017
  7. Johannes SchindelinSep 29, 2017
  8. Jeff KingSep 29, 2017
  9. Junio C HamanoSep 28, 2017
  10. Jonathan TanSep 28, 2017
  11. oidmap: map with OID as keyJonathan Tan, Sep 29, 2017
  12. Brandon WilliamsOct 2, 2017
  13. Jeff KingOct 3, 2017
  14. Jonathan TanOct 4, 2017
  15. Jeff KingOct 4, 2017
  16. Junio C HamanoOct 4, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.