We’re only measuring execution speed, not memory allocation, which is important 
too.

Yes. And besides having to collect the garbage at some point, allocation can be costly because the VM has to zero out the string bytes (or nil them if the string is not encoded) and then write on those zeroed (nilled) places with something else. It takes time.

The length of the strings is a variable as well, of course.

The order also matters, e.g.

        (String new: 7812681237643287423), 'a', 'b', 'c'

and the way you aggregate the result matters as well.

Conclusion, let’s be careful with a too simple advice.

Yes, it's much more complex than it seems when the inefficiency of naive concatenation methods is not flagrant.

Andres.

Reply via email to