ksys: Remove unnecessary null checks in SafeDelete

Deleting a null pointer has no effect -- the compiler automatically
inserts a null pointer check.
This commit is contained in:
Léo Lam 2022-02-09 02:59:55 +01:00
parent 808b21530a
commit 5f92a7b959
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
1 changed files with 2 additions and 4 deletions

View File

@ -9,8 +9,7 @@ namespace ksys::util {
/// It is safe for the pointer to be already nullptr.
template <typename T>
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 <typename T>
inline void safeDeleteArray(T*& pointer) {
if (pointer)
delete[] pointer;
delete[] pointer;
pointer = nullptr;
}