rttrorg / rttr

C++ Reflection Library
https://www.rttr.org
MIT License
3.11k stars 429 forks source link

four slow moves #342

Open dcb314 opened 2 years ago

dcb314 commented 2 years ago

Recent development versions of gcc can be made to say:

src/rttr/../rttr/detail/registration/bind_impl.h:201:67: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]

Source code is

        m_ctor = create_constructor_wrapper<first_prop_policy>(std::move(get_metadata(std::forward<Args>(args)...)),
                                                               std::move(get_default_args<type_list<Ctor_Args...>, constructor_type>(std::forward<Args>(args)...)),
                                                               std::move(create_param_infos<type_list<Ctor_Args...>, constructor_type>(std::forward<Args>(args)...)));

More of the same at:

detail/registration/bind_impl.h:427:44: warning: moving a temporary object prevents copy elision [-Wpessimizing-move] detail/registration/bind_impl.h:609:44: warning: moving a temporary object prevents copy elision [-Wpess imizing-move] detail/registration/bind_impl.h:520:44: warning: moving a temporary object prevents copy elision [-Wpess imizing-move]

A bit of code rewrite would have the code running faster, especially the first one. There are 108 cases of that.