yade-dev team mailing list archive
-
yade-dev team
-
Mailing list archive
-
Message #02740
Re: acces to sphere/wall information
No, since static_cast is called inside condition where dynamic_cast
checked the type already. It is useless to use YADE_CAST after
dynamic_cast, though (two dynamic_casts in debug mode).
Ah, true.
If I remember correctly, dynamic_casts are very slow, so I would go for
the second option.
I never measured it. It cannot be in principle slower than virtual
function dispatch (since that also has to determine exact instance type,
just like dynamic_cast), and those are used allover yade (every functor
call is a virtual function, getClassIndex is virtual as well etc.
I measured that a few years ago. Dynamic_casts where using at least 50%
of CPU time in many engines.
Static_casts use 0% of course, since they do nothing at runtime.
int sphereIds=Sphere::getClassIndexStatic();
Emanuele just showed me that this member is private currently.
Bruno
--
_______________
Chareyre Bruno
Maître de Conférences
Grenoble INP
Laboratoire 3SR - bureau E145
BP 53 - 38041, Grenoble cedex 9 - France
Tél : 33 4 56 52 86 21
Fax : 33 4 76 82 70 43
________________
Follow ups
References