This is the mail archive of the gcc-patches@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: [PATCH] Optimize sprintf(buffer,"foo")


Roger Sayle <roger@eyesopen.com> writes:

> The following patch optimizes both sprintf(buffer,"foo") and
> sprintf(dst,"%s",src) into calls to strcpy, and if the result
> of the sprintf is required, potentially an additional call to
> strlen.  The performance of strcpy+strlen is better than that
> the equivalent sprintf on most platforms, especially as both
> strcpy/memcpy and strlen may get inlined, and the strlen often
> isn't required or can be determined to be a constant at compile
> time.

This is OK.

-- 
- Geoffrey Keating <geoffk@geoffk.org>


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