|Ada 95 Quality and Style Guide||Chapter 10|
10.4.3 Unconstrained Records
Use fixed-size components for records when measured performance indicates.
examplesubtype Line_Range is Integer range 0 .. Max_Lines; subtype Length_Range is Integer range 0 .. Max_Length; -- Note that Max_Lines and Max_Length need to be static type Paragraph_Body is array (Line_Range range <>, Length_Range range <>) of Character; type Paragraph (Lines : Line_Range := 0; Line_Length : Length_Range := 0) is record Text : Paragraph_Body (1 .. Lines, 1 .. Line_Length); end record;
Determine the size and speed impact of unconstrained records having components depending on discriminants. Some compilers will allocate the maximum possible size to each object of the type; others will use pointers to the dependent components, incurring a possible heap performance penalty. Consider the possibility of using fixed-size components.
|< Previous Page||Search||Contents||Index||Next Page >|