strcat+strcat+strcat == baaad

Jeremy White jwhite at codeweavers.com
Sat Nov 30 20:55:06 CST 2002


> > 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);
> 

While I agree with Alexandre that the argument for this change
based on efficiency is not compelling, I find the resulting
clarity of code refreshing.  And perhaps it's not our top priority,
but I think if we can encourage folks to tighten the code,
that would be a Good Thing (TM).




More information about the wine-devel mailing list