Calling nested procedures requires that an extra hidden parameter (the backchain pointer) is passed. As a result, the fewer nested procedures that your application contains, the faster it runs.
To improve the performance of your application, you can convert a mother-daughter pair of nested procedures into level-1 sister procedures inside of a package. This conversion is possible if your nested procedure does not rely on any of the automatic and internal static variables declared in its parent procedures.
If procedure b in Example with nested procedures does not use any of the variables declared in a, you can improve the performance of both procedures by reorganizing them into the package illustrated in Example with packaged procedures.
a: proc;
dcl (i,j,k) fixed bin;
dcl ib based fixed bin;
.
.
.
call b( addr(i) );
.
.
.
b: proc( px );
dcl px pointer;
display( px->ib );
end;
end;
p: package exports( a );
dcl ib based fixed bin;
a: proc;
dcl (i,j,k) fixed bin;
.
.
.
call b( addr(i) );
.
.
.
end;
b: proc( px );
dcl px pointer;
display( px->ib );
end;
end p;