my ideas for array operations
Frits van Bommel
fvbommel at REMwOVExCAPSs.nl
Mon Oct 8 02:02:32 PDT 2007
Janice Caron wrote:
> On 10/8/07, dennis luehring <dl.soluz at gmx.net> wrote:
>> only if the compiler don't understand whats going on
>> who says that a compiler need to seperate each concatenate in a single
>> operation? its the compilers job to use an efficent way
>
> That's a very interesting question. I have absolutely no idea what the
> answer is. Will the compiler optimize a~b~c~d~e~f~g~h into a single
> allocation and some copying? I don't know. I hope so, but I suspect
> not.
As I wrote in my previous post (which I started before my seeing this
post of yours) DMD will optimize into a single alloc, but GDC won't.
I've filed a bug[1] for the latter, since the multi-concat function is
available in gphobos and is even called by the generated code but only
for two arrays at a time (thus defeating the purpose).
[1]: http://d.puremagic.com/issues/show_bug.cgi?id=1556
> The existence of a cat() function would certainly encourage people to
> write code in a concatenation-optimal way though.
>
> (Note: I am /not/ suggesting that such a feature be added to D,
> because the function is just too easy to write).
The optimization should be pretty easy for the compiler (and is in fact
performed by DMD, even without -O), and just using concats looks cleaner
IMHO.
More information about the Digitalmars-d
mailing list