Optimizing Parameter Handling

You can optimize the way parameters are handled as follows:

Put the parameters in the CALL statement in the same order as their descriptions in the called program's Linkage Section.

Ensure that any Linkage Section items that are not referred to in the Procedure Division header appear after those that do.

Avoid making many references to linkage items. These include items that are defined in the Linkage Section, items set to CBL_ALLOC_MEM allocated memory, and items defined as EXTERNAL.

It is always slower to access linkage items than Working-Storage Section items. If a Linkage Section item is used frequently, it is faster to move it into a Working-Storage Section when the program is entered and move it back to the Linkage Section if necessary before returning to the calling program. Instead of the Linkage Section item, the Working-Storage Section item should then be accessed throughout the program.

If a linkage parameter is optional, you can detect its presence using a statement such as:
IF address of linkage-item NOT = null

However, this statement works only if the NOPARAMCOUNTCHECK Compiler directive is specified. This construct is considered poor programming practice.