[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9
From: |
Paul Eggert |
Subject: |
Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9 |
Date: |
Wed, 22 Dec 2010 15:25:18 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 |
On 12/22/10 13:47, Bruno Haible wrote:
> Why do people do this? It appears to be slower than just calling
> asprintf, because it has to parse the format string and produce
> the expansion twice.
In the case of coreutils, the snprintf (NULL, 0, ....) is invoked
just once, to find out the size of the buffer needed. Then
the buffer is allocated (once) and sprintf (buf, size, ...) is
invoked many times on the same buffer. For this sort
of application I expect that switching to asprintf would hurt
performance, since asprintf would need to allocate and free the buffer
many times.
- [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Paul Eggert, 2010/12/21
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Bruno Haible, 2010/12/21
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Bruno Haible, 2010/12/21
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Eric Blake, 2010/12/21
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Paul Eggert, 2010/12/21
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ... ) to Solaris 8 and 9, Bruno Haible, 2010/12/22
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Paul Eggert, 2010/12/22
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9, Paul Eggert, 2010/12/24
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ... ) to Solaris 8 and 9, Bruno Haible, 2010/12/22
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ... ) to Solaris 8 and 9, Jim Meyering, 2010/12/22
- Re: [PATCH] snprintf: port snprintf (NULL, 0, ...) to Solaris 8 and 9,
Paul Eggert <=