Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-08-08 13:04:03

"Philippe A. Bouchard" <philippeb_at_[hidden]> wrote in message
> [...]
> Since the memory block is aligned, substracting an integer from it
> will still result a an aligned memory reference:

Ok, I just noticed how you allocate the extra two ints in operator new.
That explains a lot of things, but seems dubious at best.

> [...]
> I mention this before, but get() will result in 1 operator [] () call plus
> operator + () call only. shared_ptr<> may have a faster get() but let's
> forget ptr<> is slower only with types depending on virtual tables; it is
> fast when you use simple types like ptr<int>.

To be honest, I don't use simple types with shared_ptr. I usually don't
have a need.

> sort()ing a container with shared_ptr<> is not faster in the end because
> the copy constructor of ptr<> requires less CPU cycles (and memory)
> since there's only one T * to copy. Not to mention the allocation &
> deallocation time required by shared_ptr<> is doubled.
> [...]

But there are two dereferences for every comparison in a sort, so even
though a swap takes three copies, you don't necessarily swap on every
comparison. It seems possible that there is no appreciable difference
in a large number of cases.


Boost list run by bdawes at, gregod at, cpdaniel at, john at