On Tue, Oct 09, 2007 at 09:46:35PM +0100, Heikki Linnakangas wrote:
> Essentially,
> 
> sprintf(dest, "%d-%d-%d", a, b, c);
> 
> is transformed into:
> 
> dest += sprintf_prim_d(dest, a);
> *(dest++) = '-';
> dest += sprintf_prim_d(dest, b);
> *(dest++) = '-';
> dest += sprintf_prim_d(dest, c);
> 
> Where sprintf_prim_d is a new library function that converts an integer
> to a string, like sprintf(dest, "%d", integer).

If your program has one or two dominant sprintf calls (as in the example
that motivated this exercise), it pays off.  But for a large program with
thousands of {,s,f}printf calls, this kind of code size expansion could
easily hurt instead of help.  Without some data showing a payoff for
large programs, I don't think that this kind of exercise would pay off.
And then consider that any solution has to work correctly with arbitrary
locales; this could be done with your proposed new library function,
but it's starting to turn into a rather big project for questionable gain.

Reply via email to