is char[] faster than string?

Adam D. Ruppe via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Apr 5 15:02:54 PDT 2017


On Wednesday, 5 April 2017 at 21:58:16 UTC, Inquie wrote:
> I have a lot of string concatenation to do and I'm wondering if 
> char[] is faster?

No, they are the same.

> Does it simply extend the buffer or are new buffers created 
> every time?

Both will extend the buffer when the runtime can guarantee it is 
allowed to, which it quite often can. Details here: 
http://dlang.org/d-array-article.html


I recommend just trying it with ~= (avoid a ~ b though, a ~= b is 
better when possible) and see how it performs before getting too 
worried about it, the built in really isn't bad.


More information about the Digitalmars-d-learn mailing list