Need help with efficiency NXC code

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
linusa
Posts: 228
Joined: 16 Oct 2010, 11:44
Location: Aachen, Germany
Contact:

Re: Need help with efficiency NXC code

Post 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.
RWTH - Mindstorms NXT Toolbox for MATLAB
state of the art in nxt remote control programming
http://www.mindstorms.rwth-aachen.de
MotorControl now also in Python, .net, and Mathematica
nxtboyiii
Posts: 366
Joined: 02 Oct 2010, 07:08
Location: Everywhere

Re: Need help with efficiency NXC code

Post by nxtboyiii »

I separated them into 2 arrays but I could hardly tell at all...
Thanks, and have a nice day,
nxtboy III

programnxt.com
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests