Ada 95 Quality and Style Guide | Chapter 10 |
10.5.7 Packed Boolean Array Shiftsguideline
When measured performance indicates, perform packed Boolean array shift operations by using slice assignments rather than repeated bit-wise assignment. example
subtype Word_Range is Integer range 0 .. 15; type Flag_Word is array (Word_Range) of Boolean; pragma Pack (Flag_Word); Word : Flag_Word; ... -- Loop to shift by one bit for Index in 0 .. 14 loop Word (Index) := Word (Index + 1); end loop; Word (15) := False; -- Use slice assignment to shift by one bit Word (0 .. 14) := Word (1 .. 15); Word (15) := False;rationale
Determine the impact of slice manipulation when shifting packed Boolean arrays. For Ada 83 implementations using packed Boolean arrays, shift operations may be much faster when slice assignments are used as opposed to for loop moving one component at a time. For Ada 95 implementations, consider using modular types instead (see Guideline 10.6.3).
< 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 |