mirror of
https://github.com/zeldaret/botw
synced 2026-07-08 21:55:02 -04:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user