Fastest way to append char to string?
bearophile
bearophileHUGS at lycos.com
Tue Dec 11 08:05:41 PST 2012
Chopin:
> Is this the fastest way to append a char to string?
>
> char c = 'a';
> string s;
> s ~= c;
>
> ?
>
> I have a program that does this many many times... and it's
> slow. So I was wondering it it could be it.
Try the appender from std.array. It's supposed to be faster, but
sometimes it's not faster. There was a patch to make it actually
faster, but I don't know if it was already merged.
But if your program is "slow", then first of all profile it with
-profile. Then define what you mean by "slow".
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list