SA0014: Assignments of instances
Function | Determines assignments to function block instances. For instances with pointer or reference variables such assignments may be risky. |
Reason | This is a performance warning. When an instance is assigned to another instance, all elements and sub elements are copied from one instance to the other. Pointers to data are also copied, but not their referenced data, so that the target instance and the source instance contain the same data after the assignment. Depending on the size of the instances, such an assignment may take a long time. If, for example, an instance is to be passed to a function for processing, it is much better to pass a pointer to the instance. A copy method can be useful for selectively copying values from one instance to another:
|
Importance | Medium |
Sample:
PROGRAM MAIN
VAR
fb1 : FB_Sample;
fb2 : FB_Sample;
END_VARfb1();
fb2 := fb1; // => SA0014