On 2013-12-03 07:36, CJS wrote:
In python a common performance tip for joining many strings together is
to use the join method. So, for example, instead of
"a" + "b" + "c"
use
''.join(["a","b","c"]).
The idea is to avoid creating temporary objects that are immediately
thrown away. It's obviously overkill for such a small number of strings,
though.

Is there any equivalent method/advice when concatenating many strings
together in D?

There's std.algorithm.joiner[1] and std.array.join[2]. I don't know if they're any more efficient than using "~". There's also std.array.Appender[3] if you want to do a lot of appending and want the most efficient way.

[1] http://dlang.org/phobos/std_algorithm.html#joiner
[2] http://dlang.org/phobos/std_array.html#.join
[3] http://dlang.org/phobos/std_array.html#.Appender

--
/Jacob Carlborg

Reply via email to