Skip to main content

10.8 Summary

  • Use the guidelines in this chapter with care; they may be hazardous to your software.

program structure

  • Use blocks to introduce late initialization when measured performance indicates .

data structures

  • Use constrained arrays when measured performance indicates.
  • Use zero-based indexing for arrays when measured performance indicates.
  • Use fixed-size components for records when measured performance indicates.
  • Define arrays of records as parallel arrays when measured performance indicates.
  • Use a sequence of assignments for an aggregation when measured performance indicates.

algorithms

  • Use incremental schemes instead of mod and rem when measured performance indicates.
  • Use the short-circuit control form when measured performance indicates.
  • Use the case statement when measured performance indicates.
  • Use hard-coded constraint checking when measured performance indicates.
  • Use column-first processing of two-dimensional arrays when measured performance indicates.
  • Use overwriting for conditional assignment when measured performance indicates.
  • When measured performance indicates, perform packed Boolean array shift operations by using slice assignments rather than repeated bit-wise assignment.
  • Use static subprogram dispatching when measured performance indicates.<

types

  • Use only simple aggregates when measured performance indicates.
  • For mutual exclusion, when measured performance indicates, use protected types as an alternative to tasking rendezvous.
  • To implement an interrupt handler, when measured performance indicates, use a protected procedure.
  • Use modular types rather than packed Boolean arrays when measured performance indicates.
  • Use the predefined bounded strings when predictable performance is an issue and measured performance indicates.
  • Use the procedural form of the string handling subprograms when measured performance indicates.
  • Use strong typing with carefully selected constraints to reduce run-time constraint checking when measured performance indicates.
  • For cases where both rendezvous and protected types are inefficient, consider the use of the Real-Time Systems Annex (Ada Reference Manual 1995, Annex D).

pragmas

  • When measured performance indicates, use pragma Inline when calling overhead is a significant portion of the routine's execution time.
  • Use pragma Restrictions to express the user's intent to abide by certain restrictions.
  • Use pragma Preelaborate where allowed.
  • Use pragma Pure where allowed.
  • Use pragma Discard_Names when the names are not needed by the application and data space is at a premium.
  • Use pragma Suppress where necessary to achieve performance requirements.
  • Use pragma Reviewable to aid in the analysis of the generated code.
note

This page of the "Ada Quality and Style Guide" has been adapted from the original work at https://en.wikibooks.org/wiki/Ada_Style_Guide, which is licensed under the Creative Commons Attribution-ShareAlike License; additional terms may apply. Page not endorsed by Wikibooks or the Ada Style Guide Wikibook authors. This page is licensed under the same license as the original work.