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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/10/2023 3:20 PM, René Scharfe wrote:
> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux