
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 -