feat(c-wrapper): little optimization on getCBackPtr

This commit is contained in:
Ronan Abhamon 2017-09-28 15:33:46 +02:00
parent 5e80df36fa
commit e783a88a31

View file

@ -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 *>();