![]() |
Blitz Support : |
From: Simon Perreault (perrea02_at_[hidden])
Date: 2003-09-15 15:33:26
On Monday September 15 2003 14:09, Julian Cummings wrote:
> The main reason not to pass by const reference here is that for the most
> typical case where the argument type is a built-in numerical type, it
> will be *slower* than passing by value because of the work required to
> access the referenced memory.
This is the only reason why it's passed by value.
Navneet: What you can do to work around this is implement in your large class
a "shallow copy" mechanism. This means that the class only holds a pointer to
the real data. Many classes can point to the same data, and the data is
deleted via reference-counting. When you copy a class by value, you copy the
data pointer and increment the reference counter.
-- Simon Perreault <perrea02_at_[hidden]> http://nomis80.org