Skip to content

Commit

Permalink
Help compilers optimize Object::cast_to()
Browse files Browse the repository at this point in the history
  • Loading branch information
RandomShaper committed Mar 6, 2024
1 parent 72a3172 commit fdc47ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -798,12 +798,12 @@ class Object {

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 {
Expand Down

0 comments on commit fdc47ad

Please sign in to comment.