Boost logo

Boost :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-10-03 06:33:20


Emil Dotchevski wrote:
> In the particular case of Boost Exception, any speed overhead it adds
> should be compared to the overhead of throwing an exception. You have
> stack unwinding and destructor calls, etc. anyway. I don't think that
> optimizing Boost Exception for speed makes any sense.
>
> Optimizing the memory allocations made by Boost Exception when info is
> added to exception objects can not be dismissed as easily, but I would
> not call those allocations unnecessary. :)

There are certainly avoidable ones:

* intrusive::map<K,V> (or using intrusive::rb_tree directly to avoid
dependencies) can replace std::map<K,shared_ptr<V> > to save one
allocation per object.

Taking it further by applying Tom Brinkman's suggestion you can
have one allocation per custom_exception (see previous post), as those
objects can be grouped. It takes a few lines of code to manage the
deletion, though.

* The shared pointer for pImpl could as well be an intrusive one
saving another allocation per throw (and as exceptions are not accessed
concurrently gets rid of the synchronization as well).

Regards,
Tobias Schwinger
- Review Manager -


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk