Fastest way to clear a multi-dimensional array?
BlitzMax Forums/BlitzMax Programming/Fastest way to clear a multi-dimensional array?
| ||
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. |
| ||
MyArray[0..99] = 0? Edit: That only works with one dimensional arrays. |
| ||
MyArray = New Int[100,100] |
| ||
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). |
| ||
Very cool games you've got there Michael. Thanks for the tips. Thanks Pert, much appreciated. |
| ||
By filling with zeros, you can useMemClear(MyArray, SizeOf(MyArray)) I suppose that this is the fastest way. |