Merge pull request #82903 from RandomShaper/cast_to_expl_null

Help compilers optimize `Object::cast_to()`
This commit is contained in:
Rémi Verschelde 2024-03-06 13:16:43 +01:00
commit 7307eef89d
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -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 {