On 30.05.2012 20:40, Joseph Rushton Wakeling wrote:
On Wednesday, 30 May 2012 at 06:06:10 UTC, Ali Çehreli wrote:
pure int[] solve(const bool[] redundancy, const ushort[LEN - 1][]
matrixes, const int[2^^LEN] bits, const int[] numbers)

Fixed-length arrays are value types and are copied on the stack. Try
passing 'bits' as 'const ref' instead of just 'const'.

This is specifically a fixed-length array issue?

I ask because I have a function in code I've written,

final pure nothrow const(CoDetResult) reputation(immutable size_t users,
immutable size_t objects, const Rating!(UserID, ObjectID, Reputation)[]
ratings)

... which repeatedly gets passed vectors of length 4,000,000 or more,
and memory usage stays at a constant level.

I didn't even realize it was possible to specify a fixed length for an
array in a function declaration.

Fixed-sized array are value types. That is if you specify size in function declaration it becomes whole another type != that of dynamic array. However fixed array is easily "convertible" to dynamic slice via arr[] syntax.

--
Dmitry Olshansky

Reply via email to