Certain operations can cause fairly long sequences of generated code. Some of these include:
- || (concatenation) involving operands of non-constant length and/or non-constant starting position.
- For certain BUILTINs, such as VERIFY, TRANSLATE, etc..., that build large tables (typically 256 bytes), avoid certain run-time evaluated arguments; for example, in the following example of TRANSLATE, which converts all commas and periods to blanks, the first usage is much better performing than the second:
- target = TRANSLATE(source, ' ', ',.');
- target = TRANSLATE(source, two_blanks, comma_period); DCL (two_blanks init(''), comma_period init(',.')) char(2) static;
- Operations on differing operand types; for example:
DCL f fixed bin(31) init(1111);
DCL c char(8);
c = ‘1234’;
f = f + c;
Require a conversion from character to fixed binary before the addition can take place.
Another example:
c = c + f;
Requires
c to be converted from a character (to fixed binary), and then converted back after the addition. In such cases, declare
c as fixed bin(31);
- In an iterative DO statement, if the BY value is negative, the control variable is decremented by the BY value until it is <= the TO value. This means that unless the BY value is a signed constant, the compiler must generate code that can handle a decrementing as well an incrementing loop. When possible, use a constant value for BY.