|
When something is passed "const" the system passes a pointer to the data... i.e. it has to copy 16 bytes. (Unless, you pass an expression or something like that, in which case it has to allocate memory, put the value of the expression into that memory... but it still passes only the address of the temp memory) However, when something is passed "value" it has to make a copy of the entire variable. So, logically, it will take longer to pass something large by value than it would by const. i.e. copyying 16 bytes is faster than copying 32,000. On Tue, 8 Oct 2002, Steve Richter wrote: > here is a performance discrepancy that happens when a string arg is passed > "const varying" ( fast ) vs "value varying" ( slow ). > > > ** arg1 is value varying. > pTestFunc1 b > dTestFunc1 pi 10a > d InString 32000a value varying > c return 'efg' > p e > > ** arg1 is const varying. > pTestFunc2 b > dTestFunc2 pi 10a > d InString 32000a const varying > c return 'efg' > p e > > d rv s 10a > d ch80 s 80a varying > > ** runs slow. 9663 milliseconds to do 50,000 calls. > c eval rv = TestFunc1( ch80 ) > c eval rv = TestFunc2( ch80 ) > > ** runs fast. 73 milliseconds to do 50,000 calls. > c eval rv = TestFunc1( ch80 ) > c eval rv = TestFunc2( ch80 ) > > why the speed difference? > > Steve Richter >
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 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.