From 56268cc4c95edf4fc4aa72654cb24e4b43ff5b14 Mon Sep 17 00:00:00 2001 From: Mathieu Lacage Date: Tue, 5 Apr 2011 21:39:39 +0200 Subject: [PATCH] bug 1094: Object::GetObject upon dlopen --- src/core/model/object.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/model/object.h b/src/core/model/object.h index 40505a661..3b8333d10 100644 --- a/src/core/model/object.h +++ b/src/core/model/object.h @@ -388,15 +388,18 @@ template Ptr Object::GetObject () const { + // This is an optimization: if the cast works (which is likely), + // things will be pretty fast. T *result = dynamic_cast (m_aggregates->buffer[0]); if (result != 0) { return Ptr (result); } + // if the cast does not work, we try to do a full type check. Ptr found = DoGetObject (T::GetTypeId ()); if (found != 0) { - return Ptr (dynamic_cast (PeekPointer (found))); + return Ptr (static_cast (PeekPointer (found))); } return 0; } @@ -408,7 +411,7 @@ Object::GetObject (TypeId tid) const Ptr found = DoGetObject (tid); if (found != 0) { - return Ptr (dynamic_cast (PeekPointer (found))); + return Ptr (static_cast (PeekPointer (found))); } return 0; }