|
On 6/18/2012 2:03 PM, Jon Paris wrote:
Not really performance since a copy is being made both ways - VALUE or "real" CONST. But see below.
Actually it would make a big difference for performance, especially for
large varying length parameters, but for any "large" parameter.
When a parameter is passed by value, even if a temporary is not needed,
the entire parameter is copied to the parameter stack. When it's passed
by reference, only the address is copied to the parameter stack.
Say the parameter is 1000A varying, and the passed value is 'abc'.
For both CONST and VALUE, 5 bytes are set when the parameter is setup by
the compiler ('abc' plus the 2-byte length prefix).
For CONST, the 16 byte address is copied to the parameter stack. For
VALUE, the entire 1002 bytes is copied to the parameter stack.
So for that particular parameter, CONST requires 16+5=21 bytes to be
handled, and VALUE requires 5+1002=1007.
For a data structure of 1000 bytes where a compiler temp is not needed,
CONST requires 16 bytes to be handled, and VALUE requires 1000 bytes.
Personally, I agree that it would be nice to have a by-copy parameter
passing option, both for performance (vs VALUE) and guaranteed parameter
safety (vs CONST).
--
Barbara
--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.