Commit e783a88a authored by Ronan's avatar Ronan

feat(c-wrapper): little optimization on getCBackPtr

parent 5e80df36
......@@ -244,7 +244,8 @@ public:
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const std::shared_ptr<CppType> &cppObject) {
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
if (!cppObject) return nullptr;
if (L_UNLIKELY(!cppObject))
return nullptr;
Variant variant = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
void *value = variant.getValue<void *>();
......@@ -261,7 +262,9 @@ public:
typename = typename std::enable_if<IsDefinedNotClonableCppObject<CppType>::value, CppType>::type
>
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (CppType *cppObject) {
if (!cppObject) return nullptr;
if (L_UNLIKELY(!cppObject))
return nullptr;
try {
return getCBackPtr(std::static_pointer_cast<CppType>(cppObject->shared_from_this()));
} catch (const std::bad_weak_ptr &e) {
......@@ -277,8 +280,10 @@ public:
typename = typename std::enable_if<IsDefinedClonableCppObject<CppType>::value, CppType>::type
>
static inline typename CppTypeMetaInfo<CppType>::cType *getCBackPtr (const CppType *cppObject) {
if (L_UNLIKELY(!cppObject))
return nullptr;
typedef typename CppTypeMetaInfo<CppType>::cType RetType;
if (!cppObject) return nullptr;
Variant variant = cppObject->getProperty("LinphonePrivate::Wrapper::cBackPtr");
void *value = variant.getValue<void *>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment