From 5f92a7b959e3930f9cc4898e8af981006410b69b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Wed, 9 Feb 2022 02:59:55 +0100 Subject: [PATCH] ksys: Remove unnecessary null checks in SafeDelete Deleting a null pointer has no effect -- the compiler automatically inserts a null pointer check. --- src/KingSystem/Utils/SafeDelete.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/KingSystem/Utils/SafeDelete.h b/src/KingSystem/Utils/SafeDelete.h index d5bca0b5..45970340 100644 --- a/src/KingSystem/Utils/SafeDelete.h +++ b/src/KingSystem/Utils/SafeDelete.h @@ -9,8 +9,7 @@ namespace ksys::util { /// It is safe for the pointer to be already nullptr. template inline void safeDelete(T*& pointer) { - if (pointer) - delete pointer; + delete pointer; pointer = nullptr; } @@ -19,8 +18,7 @@ inline void safeDelete(T*& pointer) { /// It is safe for the pointer to be already nullptr. template inline void safeDeleteArray(T*& pointer) { - if (pointer) - delete[] pointer; + delete[] pointer; pointer = nullptr; }