From: kronbichler Date: Thu, 5 Mar 2009 17:41:02 +0000 (+0000) Subject: Turn some dynamic_cast operations into static_cast (while still asserting the correct... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f43db3c2bf65d78bc0fe5db2cfa08cd44d952537;p=dealii-svn.git Turn some dynamic_cast operations into static_cast (while still asserting the correctness of the cast at run-time). This improves performance of the reinit methods that are called very often. git-svn-id: https://svn.dealii.org/trunk@18457 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/fe/fe_poly.templates.h b/deal.II/deal.II/include/fe/fe_poly.templates.h index 337cf7fbf1..9c54d47526 100644 --- a/deal.II/deal.II/include/fe/fe_poly.templates.h +++ b/deal.II/deal.II/include/fe/fe_poly.templates.h @@ -248,8 +248,9 @@ FE_Poly,1,2>::fill_fe_values (const Mapping<1,2> &ma // convert data object to internal // data for this class. fails with // an exception if that is not - // possible - InternalData &fe_data = dynamic_cast (fedata); + // possible + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -286,7 +287,10 @@ FE_Poly,2,3>::fill_fe_values (const Mapping<2,3> &ma FEValuesData<2,3> &data) const { - InternalData &fe_data = dynamic_cast (fedata); + // assert that the following dynamics + // cast is really well-defined. + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -328,8 +332,8 @@ FE_Poly,1,2>::fill_fe_values ( // an exception if that is not // possible - - InternalData &fe_data = dynamic_cast (fedata); + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -366,8 +370,8 @@ FE_Poly,2,3>::fill_fe_values (const Mapping<2,3>& mapping, Mapping<2,3>::InternalDataBase &fedata, FEValuesData<2,3> &data) const { - - InternalData &fe_data = dynamic_cast (fedata); + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -408,8 +412,8 @@ FE_Poly::fill_fe_values (const Mapping // an exception if that is not // possible - - InternalData &fe_data = dynamic_cast (fedata); + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); const UpdateFlags flags(fe_data.current_update_flags()); @@ -509,7 +513,8 @@ FE_Poly::fill_fe_face_values (const Mapping // data for this class. fails with // an exception if that is not // possible - InternalData &fe_data = dynamic_cast (fedata); + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); // offset determines which data set // to take (all data sets for all @@ -624,11 +629,12 @@ FE_Poly::fill_fe_subface_values (const Mapping // data for this class. fails with // an exception if that is not // possible - InternalData &fe_data = dynamic_cast (fedata); + Assert (dynamic_cast (&fedata) != 0, ExcInternalError()); + InternalData &fe_data = static_cast (fedata); // offset determines which data set // to take (all data sets for all - // sub-faces are stored contiguously) + // sub-faces are stored contiguously) const typename QProjector::DataSetDescriptor dsd; const typename QProjector::DataSetDescriptor offset