Page 7 of 7

Re: Need help with efficiency NXC code

Posted: 22 Aug 2011, 21:26
by linusa
nxtboyiii wrote:But how exactly could I make it not an array of structures?
Instead of

Code: Select all

map[x][y].p = ...
map[x][y].sld = ...
...
you would then use

Code: Select all

map_p[x][y] = ...
map_sld[x][y] = ...
...
i.e. each field of your previous struct now gets its own array.

This is now the point where otimizations start making the code look uglier and harder to maintain! Still, you should follow spillers advice. When you make the map array (or without structures, multiple arrays) global, you should consider using a naming scheme like e.g. this: every global variable starts with "g_". When you don't pass the big array(s) to functions, and the arrays don't contain structs, this will be 2 big optimizations.

Re: Need help with efficiency NXC code

Posted: 22 Aug 2011, 22:36
by nxtboyiii
I separated them into 2 arrays but I could hardly tell at all...