Ada 95 Quality and Style Guide Chapter 10

Chapter 10: Improving Performance - TOC - 10.5 ALGORITHMS

10.5.5 Order of Array Processing

guideline

  • Use column-first processing of two-dimensional arrays when measured performance indicates.

  • example

        type Table_Type is array (Row_Min .. Row_Max, Col_Min .. Col_Max) of ...
        Table : Table_Type;
        ...
        -- Row-order processing
        for Row in Row_Min .. Row_Max loop
           for Col in Col_Min .. Col_Max loop
              -- Process Table (Row, Col)
           end loop;
        end loop;
        -- Column-order processing
        for Col in Col_Min .. Col_Max loop
           for Row in Row_Min .. Row_Max loop
              -- Process Table (Row, Col)
           end loop;
        end loop;
    

    rationale

    Determine the impact of processing two-dimensional arrays in row-major order versus column-major order. While most Ada compilers are likely to use row-major order, it is not a requirement. In the presence of good optimization, there may be no significant difference in the above examples. Using static array bounds is also likely to be significant here. See Guidelines 10.4.1 and 10.4.2.


    < Previous Page Search Contents Index Next Page >
    1 2 3 4 5 6 7 8 9 10 11
    TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC TOC
    Appendix References Bibliography