OPTI1-Missing "const" for unmodified string parameter

Top  Previous  Next


Missing “const” for unmodified string parameter (OPTI1)


This is a list of all string parameters that you can declare with the const directive, resulting in better performance since the compiler can assume that the parameter will not be changed. For example, for a long string the reference count for the string does not need to be updated on entry and exit to the function. For other types of strings, like WideString, the string may have to be copied when passed to the function.






In this case, the parameter S should have the const directive, since it is never changed in the procedure. The compiler can generate code that is more efficient.


No warning is given for methods that are marked with the "override" directive. This is because they must follow the parameter list that the overridden method has.



See also: