mirror of
https://github.com/godotengine/godot
synced 2024-09-05 09:08:28 +00:00
Merge pull request #90394 from dsnopek/object-ptrcall-null-unlikely
Use `likely()` in `PtrToArg<T *>` when checking for null `Object *`s
This commit is contained in:
commit
ef481148b2
|
@ -159,10 +159,7 @@ MAKE_PTRARG_BY_REFERENCE(Variant);
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct PtrToArg<T *> {
|
struct PtrToArg<T *> {
|
||||||
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static T *convert(const void *p_ptr) {
|
||||||
if (p_ptr == nullptr) {
|
return likely(p_ptr) ? const_cast<T *>(*reinterpret_cast<T *const *>(p_ptr)) : nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return const_cast<T *>(*reinterpret_cast<T *const *>(p_ptr));
|
|
||||||
}
|
}
|
||||||
typedef Object *EncodeT;
|
typedef Object *EncodeT;
|
||||||
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
||||||
|
@ -173,10 +170,7 @@ struct PtrToArg<T *> {
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct PtrToArg<const T *> {
|
struct PtrToArg<const T *> {
|
||||||
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
_FORCE_INLINE_ static const T *convert(const void *p_ptr) {
|
||||||
if (p_ptr == nullptr) {
|
return likely(p_ptr) ? *reinterpret_cast<T *const *>(p_ptr) : nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return *reinterpret_cast<T *const *>(p_ptr);
|
|
||||||
}
|
}
|
||||||
typedef const Object *EncodeT;
|
typedef const Object *EncodeT;
|
||||||
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
_FORCE_INLINE_ static void encode(T *p_var, void *p_ptr) {
|
||||||
|
|
Loading…
Reference in a new issue