Optimization: try to optimistically dynamically_cast in case the requested object is the first entry in the aggregate buffer.
1.1 --- a/src/core/object.h Thu Nov 05 21:04:37 2009 +0100
1.2 +++ b/src/core/object.h Fri Nov 06 11:27:04 2009 +0100
1.3 @@ -122,7 +122,7 @@
1.4 * \returns a pointer to the requested interface or zero if it could not be found.
1.5 */
1.6 template <typename T>
1.7 - Ptr<T> GetObject (void) const;
1.8 + inline Ptr<T> GetObject (void) const;
1.9 /**
1.10 * \param tid the interface id of the requested interface
1.11 * \returns a pointer to the requested interface or zero if it could not be found.
1.12 @@ -383,6 +383,11 @@
1.13 Ptr<T>
1.14 Object::GetObject () const
1.15 {
1.16 + T *result = dynamic_cast<T *> (m_aggregates->buffer[0]);
1.17 + if (result != 0)
1.18 + {
1.19 + return Ptr<T> (result);
1.20 + }
1.21 Ptr<Object> found = DoGetObject (T::GetTypeId ());
1.22 if (found != 0)
1.23 {