Successively prepending to slices.
bearophile
bearophileHUGS at lycos.com
Wed Apr 9 16:43:26 PDT 2014
dnspies:
> efficiently, or is it better to avoid this sort of thing?
D arrays are dynamic on the right. So appending on their left is
not efficient (also here you are not prepending, you are
concatenating. Array concatenation creates a new array). In some
cases you can append on the right many items and then use
std.algorithm.reverse (don't forget the () if you use UFCS) to
reverse them. In case of doubt write little benchmarks.
Bye,
bearophile
More information about the Digitalmars-d-learn
mailing list