This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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[0] = bar; foo[1] = 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
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]