Ada 95 Quality and Style Guide Chapter 10

Chapter 10: Improving Performance - TOC - 10.5 ALGORITHMS

10.5.2 Short-Circuit Operators

guideline

  • Use the short-circuit control form when measured performance indicates.

  • example

       -- Nested "if"
       if Last >= Target_Length then
          if Buffer (1 .. Target_Length) = Target then
             ...
          end if;
       end if;
    
       -- "and then"
       if Last >= Target_Length and then Buffer (1 .. Target_Length) = Target then
          ...
       end if;
    
    

    rationale

    Determine the impact of using nested if statements versus using the and then or or else operator. One of the above may be significantly more efficient than the other.


    < 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