SA0010: Arrays with only one component
Function | Determines arrays containing only a single component. |
Reason | An array with a component can be replaced by a Base Type variable. Access to such a variable is much faster than access to a variable via an index. |
Exception | The length of an array is often determined by a constant and used as a parameter for a program. The program can then work with arrays of different lengths and does not have to be changed if the length is only 1. Such a situation should be documented accordingly. |
Importance | Low |
Samples:
PROGRAM MAIN
VAR
aEmpty1 : ARRAY [0..0] OF INT; // => SA0010
aEmpty2 : ARRAY [15..15] OF REAL; // => SA0010
END_VAR