Code Optimisation: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 9: Line 9:
These first two loop types are identical in speed, being more than twice as fast the proceeding two loop types.
These first two loop types are identical in speed, being more than twice as fast the proceeding two loop types.


"_y" from 0 to (count [0,0,0,0] - 1) step 1 do { ... };
*"_y" from 0 to (count [0,0,0,0] - 1) step 1 do { ... };
{ ... } foreach [0,0,0,0];
*{ ... } foreach [0,0,0,0];


Where as these two loops are much slower, and for maximum performance, avoided.
Where as these two loops are much slower, and for maximum performance, avoided.

Revision as of 22:38, 20 January 2010

Adding elements to an array

Getting position

Loops

These first two loop types are identical in speed, being more than twice as fast the proceeding two loop types.

  • "_y" from 0 to (count [0,0,0,0] - 1) step 1 do { ... };
  • { ... } foreach [0,0,0,0];

Where as these two loops are much slower, and for maximum performance, avoided.

  • _y=0; while {_y = _y + 1; _y < count [0,0,0,0]} do { ... };
  • for [{_y=0},{_y<(count [0,0,0,0])},{_y=_y+1}] do { ... }