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

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

From
JTJonathan Tan <jonathantanmy@google.com>
Date
Sep 28, 2017, 17:38 UTC
Message-ID
<20170928103850.449bd743d5f10f2c948b0c83@google.com>
In-Reply-To
<xmqqr2ur348z.fsf@gitster.mtv.corp.google.com>

On Thu, 28 Sep 2017 12:13:00 +0900 Junio C Hamano <gitster@pobox.com> wrote:

Show 15 quoted lines
> Jonathan Tan <jonathantanmy@google.com> writes:
> 
> > 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.
> 
> A naïve question is why this needs to duplicate so much code, just
> to build something similar in spirit to hashmap but unlike hashmap
> that can take caller-defined keys, limited to using oid as the keys,
> instead of just being a thin API wrapper that uses hashmap as its
> internal implementation detail.  
> 
> Is the way hashmap API is structured so hard to use it in such a
> way, or something?

Another reason that I probably should have mentioned is the opportunity to save 4 bytes. I didn't mention it in the commit message at first because I felt that the benefit was very specific and, as far as I know, wouldn't be seen on architectures with 8-byte-aligned pointers until we change the hash function. But I should have probably written something like this in the commit message:

    Using oidmap also saves 4 bytes per entry, compared to hashmap,
    because the hash does not need to be stored separately as an int.
    (However, alignment considerations might mean that we will not
    observe these savings until we change the hash function, since
    currently 20-byte hashes are being used.)

If we decide that the 4 bytes are not important, right now at least, I can change it so that this is a thin API wrapper over hashmap. We could always change it later.

Previous: Junio C HamanoNext: Jonathan Tan
Message 10 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.