fegennari / 3DWorld

3D Procedural Game Engine Using OpenGL
GNU General Public License v3.0
1.15k stars 89 forks source link

Remove an unnecessary null pointer check #6

Closed elfring closed 4 years ago

elfring commented 4 years ago

An extra null pointer check is not needed in a function like the destructor for the class “VertData”.

fegennari commented 4 years ago

Thanks. This isn't my code, I copied it from another project, but it's easy to change. I'm not sure if there are any more of these or how to find them.

elfring commented 4 years ago

How do you think about to use a development tool like “clang-tidy” for corresponding source code adjustments?

fegennari commented 4 years ago

Thanks, I'll look into this. There seems to be an option to run this in Visual Studio.

elfring commented 4 years ago

Thanks for your small source code improvement.

fegennari commented 4 years ago

I removed the setting of triIndex back to NULL. I'm not sure it really matters. Sometimes it's useful to leave that in because it causes less trouble if that class is used after free. I have code like that to check for use-after-free in my universe ship logic, which has quite a complex object ownership/reference counting system due to the reference cycles between ships.