Skip to content

Commit 999ea24

Browse files
committed
posible inlining.
1 parent b811508 commit 999ea24

File tree

3 files changed

+23
-32
lines changed

3 files changed

+23
-32
lines changed

RTLBenchmarkApp/src/BenchMark.cpp

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,13 @@ namespace rtl_bench
7878
void BenchMark::reflectedCall_noReturn(benchmark::State& state)
7979
{
8080
static rtl::Function sendMsg = cxx_mirror().getFunction("sendMessage").value();
81-
8281
static auto _ = []() {
83-
if (sendMsg.bind().call(g_longStr).err == rtl::error::None) {
84-
std::cout << "[rtl:0] call success.\n";
85-
}
86-
else {
87-
std::cout << "[rtl:0] call failed.\n";
82+
auto err = sendMsg.bind().call(g_longStr).err;
83+
if (err != rtl::error::None) {
84+
std::cout << "[rtl:0] err: "<< rtl::to_string(err)<<"\n";
8885
}
8986
return 0;
90-
}();
87+
}();
9188

9289
for (auto _ : state)
9390
{
@@ -102,14 +99,12 @@ namespace rtl_bench
10299
static rtl::Method sendMsg = rNode.getMethod("sendMessage").value();
103100
static rtl::RObject robj = rNode.create<rtl::alloc::Stack>().rObject;
104101
static auto _ = []() {
105-
if (sendMsg.bind(robj).call(g_longStr).err == rtl::error::None) {
106-
std::cout << "[rtl:1] call success.\n";
107-
}
108-
else {
109-
std::cout << "[rtl:1] call failed.\n";
102+
auto err = sendMsg.bind(robj).call(g_longStr).err;
103+
if (err != rtl::error::None) {
104+
std::cout << "[rtl:1] err: " << rtl::to_string(err) << "\n";
110105
}
111106
return 0;
112-
}();
107+
}();
113108

114109
for (auto _ : state)
115110
{
@@ -122,11 +117,9 @@ namespace rtl_bench
122117
{
123118
static rtl::Function getMsg = cxx_mirror().getFunction("getMessage").value();
124119
static auto _ = []() {
125-
if (getMsg.bind().call(g_longStr).err == rtl::error::None) {
126-
std::cout << "[rtl:2] call success.\n";
127-
}
128-
else {
129-
std::cout << "[rtl:2] call failed.\n";
120+
auto err = getMsg.bind().call(g_longStr).err;
121+
if (err != rtl::error::None) {
122+
std::cout << "[rtl:2] err: " << rtl::to_string(err) << "\n";
130123
}
131124
return 0;
132125
}();
@@ -144,11 +137,9 @@ namespace rtl_bench
144137
static rtl::Method getMsg = rNode.getMethod("getMessage").value();
145138
static rtl::RObject robj = rNode.create<rtl::alloc::Heap>().rObject;
146139
static auto _ = []() {
147-
if (getMsg.bind(robj).call(g_longStr).err == rtl::error::None) {
148-
std::cout << "[rtl:3] call success.\n";
149-
}
150-
else {
151-
std::cout << "[rtl:3] call failed.\n";
140+
auto err = getMsg.bind(robj).call(g_longStr).err;
141+
if (err != rtl::error::None) {
142+
std::cout << "[rtl:3] err: " << rtl::to_string(err) << "\n";
152143
}
153144
return 0;
154145
}();

ReflectionTemplateLib/access/inc/RObject.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424

2525
namespace rtl
2626
{
27-
inline RObject::RObject(const detail::RObjectId* pRObjId, std::any&& pObject, const Cloner* pCloner,
28-
const std::vector<traits::ConverterPair>* pConverters) noexcept
27+
FORCE_INLINE RObject::RObject(const detail::RObjectId* pRObjId, std::any&& pObject, const Cloner* pCloner,
28+
const std::vector<traits::ConverterPair>* pConverters) noexcept
2929
: m_object(std::forward<std::any>(pObject))
3030
, m_getClone(pCloner)
3131
, m_objectId(pRObjId)
3232
, m_converters(pConverters)
3333
{ }
3434

35-
inline RObject::RObject(RObject&& pOther) noexcept
35+
FORCE_INLINE RObject::RObject(RObject&& pOther) noexcept
3636
: m_object(std::move(pOther.m_object))
3737
, m_getClone(pOther.m_getClone)
3838
, m_objectId(pOther.m_objectId)

ReflectionTemplateLib/detail/inc/RObjectBuilder.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ namespace rtl::detail {
7878

7979
template<class T>
8080
template <rtl::alloc _allocOn> requires (_allocOn == alloc::Heap)
81-
RObject RObjectBuilder<T>::build(T&& pVal, bool pIsConstCastSafe) noexcept
81+
FORCE_INLINE RObject RObjectBuilder<T>::build(T&& pVal, bool pIsConstCastSafe) noexcept
8282
{
8383
using _T = traits::raw_t<T>;
84-
static const RObjectId robjId = RObjectId::create<std::unique_ptr<_T>, _allocOn>(pIsConstCastSafe);
84+
static const RObjectId robjId = RObjectId::create<std::unique_ptr<_T>, alloc::Heap>(pIsConstCastSafe);
8585

8686
return RObject( &robjId,
8787
std::any{
@@ -95,14 +95,14 @@ namespace rtl::detail {
9595

9696
template<class T>
9797
template <rtl::alloc _allocOn> requires (_allocOn == alloc::Stack)
98-
RObject RObjectBuilder<T>::build(T&& pVal, bool pIsConstCastSafe) noexcept
98+
FORCE_INLINE RObject RObjectBuilder<T>::build(T&& pVal, bool pIsConstCastSafe) noexcept
9999
{
100100
using _T = traits::raw_t<T>;
101101
constexpr bool isRawPointer = std::is_pointer_v<traits::remove_const_n_ref_t<T>>;
102102

103103
if constexpr (isRawPointer)
104104
{
105-
static const RObjectId robjId = RObjectId::create<T, _allocOn>(pIsConstCastSafe);
105+
static const RObjectId robjId = RObjectId::create<T, alloc::Stack>(pIsConstCastSafe);
106106
return RObject( &robjId,
107107
std::any { static_cast<const _T*>(pVal) },
108108
&buildCloner<_T>(),
@@ -113,7 +113,7 @@ namespace rtl::detail {
113113
if constexpr (traits::std_wrapper<_T>::type == Wrapper::Unique)
114114
{
115115
using U = traits::std_wrapper<_T>::value_type;
116-
static const RObjectId robjId = RObjectId::create<T, _allocOn>(pIsConstCastSafe);
116+
static const RObjectId robjId = RObjectId::create<T, alloc::Stack>(pIsConstCastSafe);
117117
return RObject( &robjId,
118118
std::any {
119119
std::in_place_type<RObjectUPtr<U>>,
@@ -125,7 +125,7 @@ namespace rtl::detail {
125125
else
126126
{
127127
static_assert(std::is_copy_constructible_v<_T>, "T must be copy-constructible (std::any requires this).");
128-
static const RObjectId robjId = RObjectId::create<T, _allocOn>(pIsConstCastSafe);
128+
static const RObjectId robjId = RObjectId::create<T, alloc::Stack>(pIsConstCastSafe);
129129
return RObject( &robjId,
130130
std::any {
131131
std::in_place_type<T>,

0 commit comments

Comments
 (0)