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

Re: [PATCH 1/3] use struct sha1_array in diff_tree_combined()

From
Jeff King <peff@peff.net>
Date
Dec 17, 2011, 11:19 UTC
Message-ID
<20111217111920.GA24917@sigill.intra.peff.net>
In-Reply-To
<4EEC7A10.3080705@lsrfire.ath.cx>
On Sat, Dec 17, 2011 at 12:16:32PM +0100, René Scharfe wrote:
Show 12 quoted lines
> >The original code is slightly more efficient, as it is able to use a
> >single malloc (because it knows the number of entries ahead of time).
> >It probably doesn't make a difference, but we could also add a
> >sha1_array_grow() for this case.
> [...]
> We coulddo that, yes.  In the case above we have the number already,
> in the other cases we'd have to count.
> 
> But I don't think it's worth it here.  ALLOC_GROW gives us 24 entries
> initially, which should be enough in most cases -- I'm not sure I
> want to see combined diff of that many tree.  And 24 times 20 bytes
> is small enough to not cause any memory allocation issues.
You're right.

I was blindly looking at the conversion without thinking about the context. Of course if you have just a few items, it's going to be irrelevant (my initial refactoring of sha1_array was to help speed up a hundreds-of-thousands of sha1s case, so I think that put me in the mindset of a large list).

Sorry for the noise.
-Peff
Previous: René Scharfe
Message 8 of 8 in “use struct sha1_array in diff_tree_combined()”
  1. 1/3 use struct sha1_array in diff_tree_combined()René Scharfe, Dec 17, 2011
  2. 2/3 pass struct commit to diff_tree_combined_merge()René Scharfe, Dec 17, 2011
  3. 3/3 submodule: use diff_tree_combined_merge() instead of diff_tree_combined()René Scharfe, Dec 17, 2011
  4. René ScharfeDec 17, 2011
  5. René ScharfeDec 17, 2011
  6. Jeff KingDec 17, 2011
  7. René ScharfeDec 17, 2011
  8. Jeff KingDec 17, 2011

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.