Please report new issues athttps://github.com/DOCGroup
The servant classes in TAO implement _downcast (a form of dynamic_cast) using strings. The first question to ask is why not use dynamic_cast? Shouldn't that be at least as efficient as using a bunch of string comparisons? The footprint should go down too. If dynamic_cast is not adequate then I suggest using function pointers as type identifiers, as follows: // IDL interface A {}; interface B : A {}; // C++ typedef char const * (servant_type_id)(); class POA_A { ... static inline char const * _id() { return "IDL:A:1.0"; } void * _downcast(servant_type_id id) { if (id == &POA_A::_id) { return static_cast<POA_A*>(this); } .... } }; class POA_B : public POA_A { ... static inline char const * _id() { return "IDL:B:1.0"; } void * _downcast(servant_type_id id) { if (id == &POA_B::_id) { return static_cast<POA_B*>(this); } if (id == &POA_A::_id) { return static_cast<POA_A*>(this); } .... } };
Jeff asked me to take care of this one since I'm currently working on skeleton refactoring detailed in bug 1369.
Mine.
When the dynamic cast could be used, the I think it makes use to reimplement also in tao/SystemException.cpp CORBA::SystemException::_tao_get_omg_exception_description Here a huge list with _is_a is used. The _downcast would then be much more efficient to be used.
Johnny, using dynamic_cast<> in the _tao_get_omg_exception_description() method would be more efficient but doing so also increases footprint slightly by a few bytes. I confirmed the footprint increase with g++ 3.4.3. That said, I did remove the _is_a() calls in the exception _downcast() methods. Since we're doing a dynamic_cast<> on a pointer, the cast won't throw and will provide the exact behavior required by _downcast(), meaning that the _is_a() calls are redundant. Implementing this change for each of the exception _downcast() methods and inlining them results in a 6K drop for SystemException.o. Not much, but every little bit helps.
Fixed. All all downcast operations now use dynamic_cast<>.
Really fixed. :-)