[OpenSCAD] Passing arrays around

Marius Kintel marius at kintel.net
Wed Sep 28 23:59:50 CEST 2011


On Sep 28, 2011, at 22:22 PM, William Adams wrote:

> Question:  Do variables get copied into functions?  If that's the case, then for my 256x256 array, I am getting 64K copies of the array, just to make one pass through the pixel values?

Arguments are passed by value in several places. For your example, see e.g. expr.cc, line 140.
Since all these values are immutable, I see no reason why it should be like this - probably just a quick and dirty implementation. Once you start pushing the boundaries, you stumble across such issues.

> would using the 'lookup' function make any difference?

Perhaps a tiny bit, but glancing at the code, I think you'll still get a bunch of copies.

I'll take a note of this and at some point do some performance testing and optimization.

 -Marius



More information about the OpenSCAD mailing list