strcat+strcat+strcat == baaad
Francois Gouget
fgouget at free.fr
Mon Dec 9 17:05:36 CST 2002
On 2 Dec 2002, Morten Welinder wrote:
[...]
>
> Unless we're talking an inner and very intensive loop, all this is a
> bit silly.
>
> However, assuming that it does make sense, sprintf variants are not
> part of the answer. They're interpreted and var-arg type
Why would vararg be a problem performance-wise?
> More like something along these lines:
>
> char *tmpdst = dst;
>
> strcpy (tmpdst, src1); tmpdst += strlen (src1);
[...]
> This works even better when the strlen calls have known results.
Except usually src* are constant strings and it's a major pain from a
maintainability and readability point of vue to have to duplicate them.
And whenever src* is not a constant, the above is twice as slow as
cpycat because each string is read twice (once by strcpy and another
time by strlen).
--
Francois Gouget fgouget at free.fr http://fgouget.free.fr/
1 + e ^ ( i * pi ) = 0
More information about the wine-devel
mailing list