cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Remove unnecessary null pointer checks

Open elfring opened this issue 5 years ago • 6 comments

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

elfring avatar Mar 20 '20 12:03 elfring

Note that "not needed" is not the same as "wrong" or "useless". In some cases where the argument is 0 most of the time, the explicit check is faster than a function call (actually 2 since delete usually calls free, and none of this gets inlined). However, I agree that the default should be a plain, unprotected call to delete, and the very few places where it is deemed profitable to keep the null pointer check need a comment explaining it.

mglisse avatar Mar 21 '20 10:03 mglisse

  • Which distribution would you expect (or actually observe) for the passing of null pointers?
  • Should pointers for valid objects be usually handled more often?

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

elfring avatar Mar 21 '20 11:03 elfring

If nobody is working on this issue i would like to work on it. Please assign it to me.

garvit170 avatar May 22 '20 15:05 garvit170

For the range tree it is not worth the effort. There is much more to do, namely a singleton for the anchor of the recursive structure.

afabri avatar May 22 '20 15:05 afabri

Sir I am a beginner and this would be my first issue so can you please suugest something according to my skill set. Thanks

garvit170 avatar May 22 '20 17:05 garvit170

I am beginner an this would be first issue.can you suggest something according to my skill set

sarveshwar22 avatar May 29 '20 11:05 sarveshwar22