apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christophe JAILLET <christophe.jail...@wanadoo.fr>
Subject Re: [PATCH] Reduce apr_[i|l|off_t_]toa memory footprint for common cases
Date Mon, 01 Apr 2013 10:21:07 GMT
Le 28/03/2013 19:32, Jeff Trawick a écrit :
> On Thu, Mar 28, 2013 at 1:38 PM, Stefan Fritsch <sf@sfritsch.de> wrote:
>> On Monday 25 March 2013, Christophe JAILLET wrote:
>>> As a first step, I noticed that apr_itoa, apr_ltoa, apr_off_t_toa
>>> 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)
>> Looks like a reasonable optimization to me.
>>
>> Cheers,
>> Stefan
> When shrinking it down to 8, why not avoid the apr_palloc altogether?
> Also, how about lower-casing the name BUFFER_SIZE since it isn't
> const?
>
>
I'm not sure it is possible to avoid the call to apr_palloc.

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


Mime
View raw message