Array efficiency & rendering buffers

Sean Kelly sean at f4.ca
Wed Jun 7 15:23:23 PDT 2006


Henrik Eneroth wrote:
>
> Passing an array to a function and then using its return would involve quite a
> bit of copying, no? Should I pass around pointers to arrays, or maybe just plain
> pointers?

Under the covers, arrays are stored as:

     struct Array {
         size_t len;
         void*  ptr;
     }

So passing by value is actually quite inexpensive.  If this wasn't 
enough, you could pass by reference via the 'inout' qualifier.

Sean



More information about the Digitalmars-d-learn mailing list