From fdc47adf1ebd6146d52af024befa115b8d64ed81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Fri, 6 Oct 2023 10:39:43 +0200 Subject: [PATCH] Help compilers optimize Object::cast_to() --- core/object/object.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/object/object.h b/core/object/object.h index f97691841fdc..cb1495296ddb 100644 --- a/core/object/object.h +++ b/core/object/object.h @@ -798,12 +798,12 @@ class Object { template static T *cast_to(Object *p_object) { - return dynamic_cast(p_object); + return p_object ? dynamic_cast(p_object) : nullptr; } template static const T *cast_to(const Object *p_object) { - return dynamic_cast(p_object); + return p_object ? dynamic_cast(p_object) : nullptr; } enum {