Re: [RFA 1/6] change gmp_string_asprintf to return an std::string

Simon Marchi
2020-11-16T20:10:40Z

On 2020-11-15 10:55 p.m., Joel Brobecker wrote:
> I don't know if that's really important in the context of this function
> which I don't think will be called often, but your suggestion raises
> a question: Which option should we favor? Allocating a memory region
> twice, or formatting twice...

I think that memory allocation is in general heavier than the formatting
part. In the best case, allocation can be very quick, but in the worst
case it can be quite costly, I guess that depends on the allocator.
Allocating could involve some locking or some syscall.

Simon