Francois Gouget <fgouget(a)free.fr> writes:
> I don't like pieces of code that go:
>
> strcpy(foo, bar1);
> strcat(foo, bar2);
> strcat(foo, bar3);
> strcat(foo, bar4);
> strcat(foo, bar5);
> strcat(foo, bar6);
>
> It's really inefficient: the cost increases quadratically with the size
> of the resulting string.
Well, no, the cost is linear. It would only be quadratic if the number
of strcat calls depended on the length of the string.
> It's more efficient to do:
>
> sprintf(foo, "%s%s%s%s%s%s", bar1,bar2,bar3,bar4,bar5,bar6);
I seriously doubt that sprintf would be faster that a couple of
strcats. And I don't think we need to worry about this kind of
micro-optimizations right now...
--
Alexandre Julliard
julliard(a)winehq.com