Which is most optimised?

BlitzMax Forums/BlitzMax Programming/Which is most optimised?

Thanks for the feedback.

The only drawbacks are needing to preallocate/premeditate how much space you're going to need ahead of time, as a `chunk` of memory, what to do when you fill up that space, and how to add or remote/insert elements of data efficiently.
I either make the array big enough to cover the maximum case scenario for the game (and maybe code a limit in-game if required) or have it so that it's a certain size, say 100 big, then when it goes over that, I add another 100 (not 1), and then you only need to grow it in chunks instead of each time you add an element (much faster!)

Regarding your last paragraph, yes I'm wondering if my particle system, which uses a TList to store the particles, should write a pointer to each particle in an array so that the array can be looped through quickly instead of the list. In fact, it should probably be an array of particles anyway, and not even use a list. I was thinking of making a TFastParticle type which uses arrays instead of lists and maybe has a reduced set of "fancy effects" so there are less "IF" statements checking for effect flags. I could even have TFastParticle1, TFastParticle2, TFastParticle3 etc which all do slightly different things. Bit crappy from an OOP point of view (unless I could use polymorphism to do it, hmm) but nice and fast for each special case.

At the end of the day, that's what it boils down to: Do you you write special harder to maintain code for situations where it needs to be well optimised? This would be a non-issue if CPUs were uber-fast but they are not fast enough yet...