You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Merge pull request #80075 from Bromeon/gdextension/optimize-ptrcalls
GDExtension: `PtrToArg::convert()` uses const-reference where possible
This commit is contained in:
@@ -41,7 +41,7 @@ struct PtrToArg {};
|
|||||||
#define MAKE_PTRARG(m_type) \
|
#define MAKE_PTRARG(m_type) \
|
||||||
template <> \
|
template <> \
|
||||||
struct PtrToArg<m_type> { \
|
struct PtrToArg<m_type> { \
|
||||||
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
|
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
|
||||||
return *reinterpret_cast<const m_type *>(p_ptr); \
|
return *reinterpret_cast<const m_type *>(p_ptr); \
|
||||||
} \
|
} \
|
||||||
typedef m_type EncodeT; \
|
typedef m_type EncodeT; \
|
||||||
@@ -51,7 +51,7 @@ struct PtrToArg {};
|
|||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
struct PtrToArg<const m_type &> { \
|
struct PtrToArg<const m_type &> { \
|
||||||
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
|
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
|
||||||
return *reinterpret_cast<const m_type *>(p_ptr); \
|
return *reinterpret_cast<const m_type *>(p_ptr); \
|
||||||
} \
|
} \
|
||||||
typedef m_type EncodeT; \
|
typedef m_type EncodeT; \
|
||||||
@@ -85,7 +85,7 @@ struct PtrToArg {};
|
|||||||
#define MAKE_PTRARG_BY_REFERENCE(m_type) \
|
#define MAKE_PTRARG_BY_REFERENCE(m_type) \
|
||||||
template <> \
|
template <> \
|
||||||
struct PtrToArg<m_type> { \
|
struct PtrToArg<m_type> { \
|
||||||
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
|
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
|
||||||
return *reinterpret_cast<const m_type *>(p_ptr); \
|
return *reinterpret_cast<const m_type *>(p_ptr); \
|
||||||
} \
|
} \
|
||||||
typedef m_type EncodeT; \
|
typedef m_type EncodeT; \
|
||||||
@@ -95,7 +95,7 @@ struct PtrToArg {};
|
|||||||
}; \
|
}; \
|
||||||
template <> \
|
template <> \
|
||||||
struct PtrToArg<const m_type &> { \
|
struct PtrToArg<const m_type &> { \
|
||||||
_FORCE_INLINE_ static m_type convert(const void *p_ptr) { \
|
_FORCE_INLINE_ static const m_type &convert(const void *p_ptr) { \
|
||||||
return *reinterpret_cast<const m_type *>(p_ptr); \
|
return *reinterpret_cast<const m_type *>(p_ptr); \
|
||||||
} \
|
} \
|
||||||
typedef m_type EncodeT; \
|
typedef m_type EncodeT; \
|
||||||
|
|||||||
@@ -145,8 +145,7 @@ struct PtrToArg<TypedArray<T>> {
|
|||||||
template <class T>
|
template <class T>
|
||||||
struct PtrToArg<const TypedArray<T> &> {
|
struct PtrToArg<const TypedArray<T> &> {
|
||||||
typedef Array EncodeT;
|
typedef Array EncodeT;
|
||||||
_FORCE_INLINE_ static TypedArray<T>
|
_FORCE_INLINE_ static TypedArray<T> convert(const void *p_ptr) {
|
||||||
convert(const void *p_ptr) {
|
|
||||||
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
|
return TypedArray<T>(*reinterpret_cast<const Array *>(p_ptr));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user