Writing Programs That Are Easily Optimized [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Writing Programs That Are Easily Optimized
To maximize the opportunities for optimization and the speed with which
your program is optimized, observe the following guidelines whenever
possible:
* Specify all possible assumptions with the ASSUME compiler option.
* Do not use system programming extensions (specify ASSUME
'PASCAL_FEATURES').
* Use local variables and parameters instead of global variables
(this helps the optimizer promote variables to registers).
* Don't use CRUNCHED, PACKED, or shortint variables.
* Don't put pointer fields in variant parts of records.
* Use unique types as often as possible (this helps the optimizer
determine which variables are possible actual parameters for the
formal parameters of routines).
* Make routines relatively small--approximately 50 executable lines
maximum (this allows the optimizer to use registers more
efficiently).
* Expand in-line any routine of fewer than five lines and any
relatively small routine that your program calls only once (see
"INLINE" in Chapter 8 ).
* Do not write a loop that contains only a routine call; put the
loop in the routine instead, or use the INLINE compiler option.
* Design loops that terminate when their control values are zero or
nil.
* Use WITH statements.
* Do not use the FORWARD and EXTERNAL directives without the ASSUME
compiler option.
* Do not use the GOTO statement.
MPE/iX 5.0 Documentation