Re: Functions pass by ref or by value? by Egbert
Egbert
Sat Aug 27 13:42:14 CDT 2005
"Joe" <joe@hotmail.com> wrote in message
news:uFzSZMzqFHA.248@TK2MSFTNGP14.phx.gbl...
>I have a function called GetRS which takes in a SQL string and returns a
>recordset object. Does this mean that a copy of the recordset is returned
>or is it passed by reference?
>
> Obviously this could have a large impact on performance for large
> recordsets.
>
Hi,
If you pass an object 'byval' it is passed as (for instance _Recordset*
pRs), while 'byref' in C++ code, would be _Recordset** pRs.
In the first, case, a pointer to the instance of the object is sent, in the
second case, a pointer to the pointer of the instance. As you understand,
you don't create a in memory-copy.
When we speak about VARIANTS, which is default for ASP and vbscript, the
same happens (more or less) with instances of objects.
But when a variant, contains a string or a date, when passed 'byval', a
fresh copy is made which is obviously slower. In our current time :),
speaking about a normal server, a PIV 3GH this is peanuts. The real benefit
is when your SQL code or other network related functions halt thread
execution.