AMOS:Optimizing Array Access

From Amiga Coding
Jump to: navigation, search

Use Dreg() for small arrays

speed increase: medium

For your most used array of 8 (or less) elements, use Dreg() instead of it (it can still hold the same range of values). Note: The Dreg() array isn't actually using the data registers; it's an AMOS internal data structure. However, it's still faster than a standard array.

Don't use:

        Dim n(7)
        For a=0 to 7:Print n(a):Next a

Use this instead:

        For a=0 To 7:Print Dreg(a):Next a

Use single dimensional arrays

speed increase: small

Use single dimensional arrays instead of two dimensional ones if appropriate.

Don't use:

         Dim A(2,100)

Use this instead:

         Dim A0(100),A1(100),A2(100)