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

Re: [PATCH v2] cache-tree: fix strbuf growth in prime_cache_tree_rec()

From
Derrick Stolee <derrickstolee@github.com>
Date
Feb 13, 2023, 13:37 UTC
Message-ID
<7c8b6420-fe69-a190-9197-0ddbb3e4a964@github.com>
In-Reply-To
<a37623c8-d2fb-aec6-3423-2d402d717959@web.de>
On 2/10/2023 3:20 PM, René Scharfe wrote:
Show 6 quoted lines
> Use size_t to store the original length of the strbuf tree_len, as
> that's the correct type.
> 
> Don't double the allocated size of the strbuf when adding a subdirectory
> name.  And the chance of the trailing slash fitting in the slack left by
> strbuf_add() is very high, so stop pre-growing the strbuf at all.
> -	int base_path_len = tree_path->len;
> +	size_t base_path_len = tree_path->len;
>  				strbuf_setlen(tree_path, base_path_len);
> -				strbuf_grow(tree_path, base_path_len + entry.pathlen + 1);
>  				strbuf_add(tree_path, entry.path, entry.pathlen);
Excellent. LGTM.
-Stolee
Previous: René Scharfe
Message 13 of 13 in “cache-tree: fix strbuf growth in prime_cache_tree_rec()”
  1. cache-tree: fix strbuf growth in prime_cache_tree_rec()René Scharfe, Feb 4, 2023
  2. Ævar Arnfjörð BjarmasonFeb 5, 2023
  3. Derrick StoleeFeb 6, 2023
  4. Ævar Arnfjörð BjarmasonFeb 6, 2023
  5. René ScharfeFeb 12, 2023
  6. Junio C HamanoFeb 6, 2023
  7. René ScharfeFeb 10, 2023
  8. René ScharfeFeb 10, 2023
  9. Junio C HamanoFeb 10, 2023
  10. Jeff KingFeb 11, 2023
  11. Junio C HamanoFeb 11, 2023
  12. cache-tree: fix strbuf growth in prime_cache_tree_rec()René Scharfe, Feb 10, 2023
  13. Derrick StoleeFeb 13, 2023

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.