Performance Impact: By Reference or By Value
You can only assign an array to a variant or (exl2000 and later) to an
dynamic variant array.
I would think passing byval would require copying the array and this would
incur a penalty.
--
Regards,
Tom Ogilvy
"TheVisionThing" wrote in message
m...
Assuming that you're not modifying a parameter within a procedure, is
there
any performance difference in passing the parameter as 'ByRef' or 'ByVal'.
For example
Dim arr as variant
arr = Array(12,40)
arr = TimesTwo(arr)
Function TimesTwo(ByRef or ByVal arr as variant)
Dim i as integer,arrTemp as variant
Redim arrTemp(ubound(arr))
For i = lbound(arr) to ubound(arr)
arrTemp(i) = 2 * arr(i)
Next
TimesTwo = arrTemp
End Function
Also can arrays only be declared as variants in situations such as this
one.
Thanks,
Wayne C.
|