summaryrefslogtreecommitdiffstats
path: root/core/object/object.h
diff options
context:
space:
mode:
authorPedro J. Estébanez <pedrojrulez@gmail.com>2023-10-06 10:39:43 +0200
committerPedro J. Estébanez <pedrojrulez@gmail.com>2024-03-06 12:45:26 +0100
commitfdc47adf1ebd6146d52af024befa115b8d64ed81 (patch)
tree5252c7bb61712ac8ef0b044904c9b089f148a860 /core/object/object.h
parent72a31722fd9a2893567697dd9dff1b1eaace8980 (diff)
downloadredot-engine-fdc47adf1ebd6146d52af024befa115b8d64ed81.tar.gz
Help compilers optimize Object::cast_to()
Diffstat (limited to 'core/object/object.h')
-rw-r--r--core/object/object.h4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/object/object.h b/core/object/object.h
index f97691841f..cb1495296d 100644
--- a/core/object/object.h
+++ b/core/object/object.h
@@ -798,12 +798,12 @@ public:
template <class T>
static T *cast_to(Object *p_object) {
- return dynamic_cast<T *>(p_object);
+ return p_object ? dynamic_cast<T *>(p_object) : nullptr;
}
template <class T>
static const T *cast_to(const Object *p_object) {
- return dynamic_cast<const T *>(p_object);
+ return p_object ? dynamic_cast<const T *>(p_object) : nullptr;
}
enum {