1818
1919namespace rtl ::detail
2020{
21- // DefaultInvoker, holds const-ref of the 'Method' and 'RObject' on which it will be invoked.
22- template <class ..._signature>
23- inline DefaultInvoker<_signature...>::DefaultInvoker(const Method& pMethod, const RObject& pTarget)
24- : m_method(pMethod)
25- , m_target(pTarget) {
26- }
27-
28-
2921/* @method: call()
3022 @params: params... (corresponding to functor associated with 'm_method')
3123 @return: RObject, indicating success of the reflected call.
3224 * invokes non-static-member-function functor associated with 'm_method' on object 'm_target'.
3325*/ template <class ..._signature>
3426 template <class ..._args>
35- inline Return DefaultInvoker<_signature...>::call(_args&& ...params) const noexcept
27+ FORCE_INLINE Return DefaultInvoker<_signature...>::call(_args&& ...params) const noexcept
3628 {
3729 // Only static-member-functions have Qualifier- 'methodQ::None'
38- if (m_method. getQualifier () == methodQ::None) {
39- return static_cast <Function>(m_method).bind ().call (std::forward<_args>(params)...);
30+ if (m_method-> getQualifier () == methodQ::None) [[unlikely]] {
31+ return static_cast <Function>(* m_method).bind ().call (std::forward<_args>(params)...);
4032 }
41- if (m_target. isEmpty ()) {
33+ else if (m_target-> isEmpty ()) [[unlikely]] {
4234 // if the target is empty.
43- return { error::EmptyRObject, RObject{ } };
35+ return { error::EmptyRObject, RObject{} };
4436 }
45- if (m_target. getTypeId () != m_method. getRecordTypeId ()) {
37+ else if (m_target-> getTypeId () != m_method-> getRecordTypeId ()) [[unlikely]] {
4638 // if the m_target's type-id & type-id of the 'class/struct' owner of the associated functor(m_method's) do not match.
47- return { error::TargetMismatch, RObject{ } };
48- }
49- if constexpr (sizeof ...(_signature) == 0 ) {
50- // executes when bind doesn't have any explicit signature types specified. (e.g. perfect-forwaring)
51- return Invoker<traits::remove_const_n_ref_t <_args>...>::invoke (m_method, m_target, std::forward<_args>(params)...);
39+ return { error::TargetMismatch, RObject{} };
5240 }
53- else {
54- return Invoker<_signature...>::invoke (m_method, m_target, std::forward<_args>(params)...);
41+ else [[likely]]
42+ {
43+ if constexpr (sizeof ...(_signature) == 0 ) {
44+ // executes when bind doesn't have any explicit signature types specified. (e.g. perfect-forwaring)
45+ return Invoker<traits::remove_const_n_ref_t <_args>...>::invoke (*m_method, *m_target, std::forward<_args>(params)...);
46+ }
47+ else {
48+ return Invoker<_signature...>::invoke (*m_method, *m_target, std::forward<_args>(params)...);
49+ }
5550 }
5651 }
5752
@@ -60,15 +55,15 @@ namespace rtl::detail
6055 template <class ..._signature>
6156 template <class ..._invokSignature>
6257 template <class ..._args>
63- inline Return
58+ FORCE_INLINE Return
6459 DefaultInvoker<_signature...>::Invoker<_invokSignature...>::invoke(const Method& pMethod,
6560 const RObject& pTarget,
6661 _args&&... params)
6762 {
6863 using containerConst = detail::MethodContainer<detail::methodQ::Const, _invokSignature...>;
6964 std::size_t constMethodIndex = pMethod.hasSignatureId (containerConst::getContainerId ());
7065
71- if (constMethodIndex != rtl::index_none)
66+ if (constMethodIndex != rtl::index_none) [[likely]]
7267 {
7368 return containerConst::template forwardCall<_args...>(pTarget, constMethodIndex, std::forward<_args>(params)...);
7469 }
@@ -92,38 +87,33 @@ namespace rtl::detail
9287
9388namespace rtl ::detail
9489{
95- // NonConstInvoker, holds const-ref of the 'Method' and 'RObject' on which it will be invoked.
96- template <class ..._signature>
97- inline NonConstInvoker<_signature...>::NonConstInvoker(const Method& pMethod, const RObject& pTarget)
98- : m_method(pMethod)
99- , m_target(pTarget) {
100- }
101-
102-
10390/* @method: call()
10491 @params: params... (corresponding to functor associated with 'm_method')
10592 @return: RObject, indicating success of the reflected call.
10693 * invokes non-static-member-function functor associated with 'm_method' on object 'm_target'.
10794*/ template <class ..._signature>
10895 template <class ..._args>
109- inline Return NonConstInvoker<_signature...>::call(_args&& ...params) const noexcept
96+ FORCE_INLINE Return NonConstInvoker<_signature...>::call(_args&& ...params) const noexcept
11097 {
111- if (m_method. getQualifier () == methodQ::None) {
112- return static_cast <Function>(m_method).bind ().call (std::forward<_args>(params)...);
98+ if (m_method-> getQualifier () == methodQ::None) [[unlikely]] {
99+ return static_cast <Function>(* m_method).bind ().call (std::forward<_args>(params)...);
113100 }
114- if (m_target. isEmpty ()) {
101+ else if (m_target-> isEmpty ()) [[unlikely]] {
115102 // if the target is empty.
116103 return { error::EmptyRObject, RObject{} };
117104 }
118- if (m_target. getTypeId () != m_method. getRecordTypeId ()) {
105+ else if (m_target-> getTypeId () != m_method-> getRecordTypeId ()) [[unlikely]] {
119106 // if the m_target's type-id & type-id of the 'class/struct' owner of the associated functor(m_method's) do not match.
120107 return { error::TargetMismatch, RObject{} };
121108 }
122- if constexpr (sizeof ...(_signature) == 0 ) {
123- return Invoker<traits::remove_const_n_ref_t <_args>...>::invoke (m_method, m_target, std::forward<_args>(params)...);
124- }
125- else {
126- return Invoker<_signature...>::invoke (m_method, m_target, std::forward<_args>(params)...);
109+ else [[likely]]
110+ {
111+ if constexpr (sizeof ...(_signature) == 0 ) {
112+ return Invoker<traits::remove_const_n_ref_t <_args>...>::invoke (*m_method, *m_target, std::forward<_args>(params)...);
113+ }
114+ else {
115+ return Invoker<_signature...>::invoke (*m_method, *m_target, std::forward<_args>(params)...);
116+ }
127117 }
128118 }
129119
@@ -132,14 +122,14 @@ namespace rtl::detail
132122 template <class ..._signature>
133123 template <class ..._invokSignature>
134124 template <class ..._args>
135- inline Return
125+ FORCE_INLINE Return
136126 NonConstInvoker<_signature...>::Invoker<_invokSignature...>::invoke(const Method& pMethod,
137127 const RObject& pTarget,
138128 _args&&... params)
139129 {
140130 using container0 = detail::MethodContainer<detail::methodQ::NonConst, _invokSignature...>;
141131 const std::size_t index = pMethod.hasSignatureId (container0::getContainerId ());
142- if (index != rtl::index_none) {
132+ if (index != rtl::index_none) [[likely]] {
143133 return container0::template forwardCall<_args...>(pTarget, index, std::forward<_args>(params)...);
144134 }
145135 else
0 commit comments