[Pharo-dev] Efficient string concatenation - proposed new
avalloud at smalltalk.comcastbiz.net
Sun Nov 17 15:54:16 EST 2013
> 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.
More information about the Pharo-dev