This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Optimize sprintf(buffer,"foo")
- From: Geoff Keating <geoffk at geoffk dot org>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: 22 Jun 2003 16:51:29 -0700
- Subject: Re: [PATCH] Optimize sprintf(buffer,"foo")
- References: <Pine.LNX.4.44.0306221601070.20426-100000@www.eyesopen.com>
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>