On Mon, 8 Oct 2007, Heikki Linnakangas wrote:

> sprintf(dest, "%d", arg1); -> a new function that does the same thing,
> but without the overhead of parsing the format string. Like itoa on some
> platforms. We could inline it as well. That would allow further
> optimizations, if for example the compiler knows that arg1 is within a
> certain range (do we do that kind of optimizations?)
>
> sprintf(dest, "constant%...", args...) -> memcpy(dest, "constant", 8);
> sprintf(dest+8, "%...", args...);
>
> sprintf(dest, "%dconstant%...", args1, args...) -> sprintf(dest, "%d",
> args1); memcpy(dest+X, "constant", 8); sprintf(dest+XX, "%...", args...);

In my experience changing one library call into several creates code bloat
more often than it improves runtime speed.  I think you should only do
this when profile feedback indicates you've hit a heavily used spot in
your code.

E.g. should we turn printf("ab") into putchar('a'); putchar('b'); ?
I'd say not, unless that code was a hot spot.

One simplification I don't believe we do yet, that should always be a win,
is turning:   sprintf (foo, "%c", bar);   into:    *foo = bar;

                --Kaveh
--
Kaveh R. Ghazi                  [EMAIL PROTECTED]

Reply via email to