×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
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).
As an Amazon Associate we earn from qualifying purchases.