PDA

View Full Version : Flat Array vs Multidimensional Array



Dark Viper
June 6th, 2007, 05:11 AM
For a game I'm making I've tried to stick with using flat arrays as much as possible because I read somewhere that its faster than using multidimensional arrays. I just need to know if anyone knows or can point me to any place which discusses the speed difference (if there is any).

Using multidimensional arrays would make my coding much easier but if its slower than flat arrays I'm willing to persevere for the better execution time.

Any thoughts?

Dazzer
June 6th, 2007, 05:17 AM
I wouldn't worry too much about it.

Multidim arrays are just fine.

dthought
June 7th, 2007, 01:36 AM
Don't try to pre-emptively optimise your code with things like that... if you need to change them later, you can. Work on getting it going first, optimise second.

ajcates
June 7th, 2007, 03:31 AM
well studying how optimization work is a good thing, you can get you code working, and if you planed it right, it should be easier to optimize. the speed difference should only be seen if you have a mutidem array of hundreds of items. also the bigger the array, the longer its going to take to loop thur it.