Le 28/03/2013 19:32, Jeff Trawick a écrit :I'm not sure it is possible to avoid the call to apr_palloc.
On Thu, Mar 28, 2013 at 1:38 PM, Stefan Fritsch <sf@sfritsch.de> wrote:
On Monday 25 March 2013, Christophe JAILLET wrote:When shrinking it down to 8, why not avoid the apr_palloc altogether?
As a first step, I noticed that apr_itoa, apr_ltoa, apr_off_t_toaLooks like a reasonable optimization to me.
could be tweaked to require less memory for some common cases.
The attached patch reduces memory use for small values, that is to
say for strings that fit in 8 bytes (including NULL)
Cheers,
Stefan
Also, how about lower-casing the name BUFFER_SIZE since it isn't
const?
For BUFFER_SIZE, I 100% agree with you. Previously it was a 'const int', and I just left it as it was.
There are also some tab vs space possible clean-up in these functions.
Finally, even if the 3 functions work the same way, they have different way to write it:
*--start = '0' + (n % 10);
*--start = (char)('0' + (n % 10));
*--start = '0' + (char)(n % 10);
The 2nd version is, IMO, the best one.
I didn't include it in my patch to reduce the differences.
CJ