Jonathan M Davis:
> Personally, I'd advise you to just use dynamic arrays unless you do
> some profiling and find that a static array is better in a particular case.

To program you need a less naive view. I sometimes start using dynamic arrays 
everywhere because they are handy, then I profile code and then replace some 
critical allocations of dynamic arrays with static arrays, and I usually see 
good speed-ups. With some brain you can often find a static size (or a way to 
compute it statically) that is good for the algorithm/problem you are working 
on. In such cases using a static array is often better, the GC doesn't need to 
deallocate it, and heap activity is one of the most important causes of low 
performance in programs (or if they are allocated inside class/struct instances 
you remove some heap allocations, coalescing them). Static arrays are simpler, 
so in some situations they can make the code simpler.

Bye,
bearophile

Reply via email to