openh264 icon indicating copy to clipboard operation
openh264 copied to clipboard

Remove unnecessary null pointer checks

Open elfring opened this issue 12 years ago • 7 comments

An extra null pointer check is not needed in functions like the following.

elfring avatar Dec 10 '13 21:12 elfring

We think it is safe to check null pointer for the function parameter. And in these cases, it will not impact the performance as these checks are in the very high level. if it is in the MB loop, we should avoid the check for performance.

kali2 avatar Dec 12 '13 08:12 kali2

I am not concerned about input parameter validation here. I would appreciate if some null pointer checks can be deleted for improved execution speed because the corresponding resource release functions should provide the desired safety check, shouldn't it?

elfring avatar Dec 12 '13 14:12 elfring

null-checks are essentially free. Its a well predicted branch. Removing them won't provide a speedup. However, those checks are indeed redundant and removing them would be cleaner. @kali2, why do you need those checks?

andreasgal avatar Dec 12 '13 14:12 andreasgal

I guess that unneeded null pointer checks have got unwanted effects on run time behaviour. A source code clean-up might help here.

elfring avatar Dec 12 '13 14:12 elfring

After review all the cases you mentioned, I agree with that the null pointer check before delete is redundant. Thanks for your care. But in other cases, such as function parameter check, and check after open file, I think they it is a good coding style.

kali2 avatar Dec 13 '13 02:12 kali2

Are you going to remove "redundant" pointer checks before delete calls? Will the affected source code places be fixed?

elfring avatar Dec 16 '13 13:12 elfring

We are focus on fixing the issue of support asm code in 64-bit mode. It is appreciated if you would like to do it. Thanks!

kali2 avatar Dec 23 '13 09:12 kali2