E
Erik
On Tue, 10 Feb 2004 13:49:46 GMT, the right honourable
i think one only can explain this speed difference if one looks at the
processor in question and to the assembler code involved.
Which would bring the question/answer off-topic.
frgr
Erik
[ Don't top-post, please. ]
*Ideally* call by address is faster because call by value makes a new copy
of the argument everytime you call the function.
Call by address does no copies instead pass the address of the variable as
is.
That is the theory, based on a very restricted view of a rather
old-fashioned kind of implementation, with no arguments passed in
registers and rather larger objects than pointers. Actual practice
doesn't always agree with this theory.
In fact, in practice, which objects will be faster passed as pointers
and which are faster passed directly depends entirely on the
architecture, the compiler, and possibly even on the generation of the
architecture (i.e., it could differ between a Pentium II and a Pentium
III). The only way to know which is best for you is to measure, and not
to assume that your measurements are correct for others.
Even then, in most cases the difference between pointer and value
passing is likely to be dwarfed by algorithmic choices. If passing a
pointer makes calling the function slightly faster, but actually doing
anything inside the function slower, more complicated, and more error-
prone, only a fool uses the pointer. Ditto vice versa.
Richard
i think one only can explain this speed difference if one looks at the
processor in question and to the assembler code involved.
Which would bring the question/answer off-topic.
frgr
Erik