Re: byVal Vs. byRef
"Armin Zingler" <az.nospam@free net.de> schrieb[color=blue]
> "Rob Panosh" <rob_!!!NO!!!SP AM!!!_panosh@as dsoftadfdware.c om>
> schrieb[color=green]
> > My guess byRef would have better performance because it doesn't
> > have to make a copied of the reference.[/color]
>
> Performance difference byval and byref when passing reference types
> is close to zero (or _is_ zero). Both store a 4-byte value on the
> stack.[/color]
Should be: ....difference between byval and byref...
In addition: The difference when passing value types depends on the size of
the value type. Passing a value type ByRef always stores 4 byte on the
stack. Passing it ByVal stores the whole object on the stack, so the bigger
the value type, the slower. But, as it has already been mentioned, the
decision to use ByVal or ByRef should not depend on this, but on whether the
passed *variable* should be changable (and the variable contains a reference
with reference types and the whole object with value types...)
--
Armin
"Armin Zingler" <az.nospam@free net.de> schrieb[color=blue]
> "Rob Panosh" <rob_!!!NO!!!SP AM!!!_panosh@as dsoftadfdware.c om>
> schrieb[color=green]
> > My guess byRef would have better performance because it doesn't
> > have to make a copied of the reference.[/color]
>
> Performance difference byval and byref when passing reference types
> is close to zero (or _is_ zero). Both store a 4-byte value on the
> stack.[/color]
Should be: ....difference between byval and byref...
In addition: The difference when passing value types depends on the size of
the value type. Passing a value type ByRef always stores 4 byte on the
stack. Passing it ByVal stores the whole object on the stack, so the bigger
the value type, the slower. But, as it has already been mentioned, the
decision to use ByVal or ByRef should not depend on this, but on whether the
passed *variable* should be changable (and the variable contains a reference
with reference types and the whole object with value types...)
--
Armin
Comment