Fastest way to clear a multi-dimensional array?

BlitzMax Forums/BlitzMax Programming/Fastest way to clear a multi-dimensional array?

Chroma(Posted 2007) [#1]
Consider MyArray[100,100]. Instead of doing for y = 0 to 99 and x = 0 to 99 MyArray[a,b] = 0...is there a faster, one lined way to do this?

I'd like to just do a MyArray = Null but of course that'd be too easy.


daaan(Posted 2007) [#2]
MyArray[0..99] = 0?

Edit: That only works with one dimensional arrays.


Perturbatio(Posted 2007) [#3]
MyArray = New Int[100,100]



Michael Reitzenstein(Posted 2007) [#4]
You should write your code in the neatest, clearest way possible and profile it at the end to figure out what's slow (most of the time it'll be three or four functions that need to be rewritten).


Chroma(Posted 2007) [#5]
Very cool games you've got there Michael. Thanks for the tips.

Thanks Pert, much appreciated.


Vertex(Posted 2007) [#6]
By filling with zeros, you can use
MemClear(MyArray, SizeOf(MyArray))

I suppose that this is the fastest way.