Array efficiency & rendering buffers
Henrik Eneroth
Henrik_member at pathlink.com
Wed Jun 7 15:08:20 PDT 2006
Hello!
I am right now staring at some C++ code about to be converted to D. It's a bunch
of renderers and rendering buffers. Now, in C++ it was implemented so that you
would allocate a bit of memory yourself and then send it to the rendering buffer
- basically saying "hey, use this".
Operations were then done via this buffer, and after it was done, you just
passed the pointer to the next rendering buffer and so on, until your hearts
content. Multiple renderers could operate directly on the same bit of memory
this way, and little to no memory was actually copied anywhere.
Now I am all for doing things the D way when porting to D, but I feel that I'm
not all that experienced with the language yet and thus I would like to hear
some opinions so that I don't implement anything unnecessary, naive or unstable.
Fast renderers and simplicity of code is of course what I am heading for here,
but in that order.
Could I use plain arrays to achieve this functionality, or will such an
implementation make it crawl at a snails pace compared to it's older C++ cousin?
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? What would be the data storage method of choice when implementing
renderers and rendering buffers where efficiency obviously is of the essence?
Best regards,
Henrik
More information about the Digitalmars-d-learn
mailing list