This is the mail archive of the
mailing list for the GCC project.
Re: Preparsing sprintf format strings
On Wed, 10 Oct 2007, Joe Buck wrote:
> On Wed, Oct 10, 2007 at 12:12:25AM -0400, Kaveh R. GHAZI wrote:
> > One simplification I don't believe we do yet, that should always be a win,
> > is turning: sprintf (foo, "%c", bar); into: *foo = bar;
> You need the null terminator: foo = bar; foo = 0;
Yeah, my oops. Two 1-byte stores is still faster (and smaller!) than a
sprintf function call with three arguments.
> But these things are rarely going to be a huge win, and I get
> the impression that competing compiler developers only do them
> when they help with standard benchmarks.
Their loss. I agree with avoiding these micro opts when they cause bloat.
But when you win in both size and speed, IMHO we should do it.
Kaveh R. Ghazi firstname.lastname@example.org