Ada 95 Quality and Style Guide | Chapter 10 |
10.6.3 Bit Operations on Modular Typesguideline
Use modular types rather than packed Boolean arrays when measured performance indicates. example
-- (1) Packed Boolean arrays -- (See ACES V2.0, test "dr_ba_bool_arrays_11") type Set is array (0 .. 15) of Boolean; pragma Pack (Set); S1 : Set; S2 : Set; Empty : Set := (Set'Range => False); Result : Boolean; ... -- Is S1 a subset of S2? Result := ((S1 and not S2) = Empty); --------------------------------------------------------------------- -- (2) Modular types -- (See ACES V2.0, test "a9_ms_modular_oper_02") type Set is mod 16; S1 : Set; S2 : Set; Empty : Set := 0; Result : Boolean; ... -- Is S1 a subset of S2? Result := ((S1 and not S2) = Empty);rationale
Determine the impact of performing bit-wise operations on modular types. The performance of these operations may be significantly different from similar operations on packed Boolean arrays. See also Guideline 10.5.7.
< 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 |