On Mon, Apr 1, 2013 at 6:21 AM, Christophe JAILLET < christophe.jaillet@wanadoo.fr> wrote: > Le 28/03/2013 19:32, Jeff Trawick a écrit : > > On Thu, Mar 28, 2013 at 1:38 PM, Stefan Fritsch 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. > You're correct, of course :) > > 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. > preferred by me too > > I didn't include it in my patch to reduce the differences. > > CJ > -- Born in Roswell... married an alien... http://emptyhammock.com/