StarRuler2-Source icon indicating copy to clipboard operation
StarRuler2-Source copied to clipboard

Remove unnecessary null pointer checks

Open elfring opened this issue 5 years ago • 5 comments

If you'd like to improve these sorts of checks, we do welcome pull requests.

That second request is not redundant: glDeleteProgram is a potentially expensive call even in the case of a 0 id.

ThyReaper avatar Jul 25 '18 16:07 ThyReaper

That second request is not redundant: glDeleteProgram is a potentially expensive call even in the case of a 0 id.

I am curious about this, as the documents on khronos for OpenGL explicitly state that passing 0 will be silently ignored by glDeleteProgram. The only assumption I could make is that it has to do with the assumed cost of the call versus the logic check, no? If that isn't the concern then removing the unnecessary check should be fine I would assume.

AtlaStar avatar Sep 26 '18 22:09 AtlaStar

That second request is not redundant: glDeleteProgram is a potentially expensive call even in the case of a 0 id.

I am curious about this, as the documents on khronos for OpenGL explicitly state that passing 0 will be silently ignored by glDeleteProgram. The only assumption I could make is that it has to do with the assumed cost of the call versus the logic check, no? If that isn't the concern then removing the unnecessary check should be fine I would assume.

In practice, it's dangerous to rely on the OpenGL docs. I vaguely remember this sort of call outright crashing on a particular Intel driver, for example.

Regardless, those docs only say it will be silently ignored, not how. If the call is still passed to the GPU, rather than being filtered at the API call level, it can still be expensive.

ThyReaper avatar Sep 26 '18 22:09 ThyReaper

…, those docs only say it will be silently ignored, not how.

  • How do you think about to achieve a better wording there anyhow?
  • Can it usually mean that an immediate return will be performed by these functions after the input parameter validation?

elfring avatar Sep 27 '18 06:09 elfring

…, those docs only say it will be silently ignored, not how.

  • How do you think about to achieve a better wording there anyhow?
  • Can it usually mean that an immediate return will be performed by these functions after the input parameter validation?

In the docs? It's a moot point. Implementations in the wild do whatever they feel like, and the docs only loosely describe the behavior most of the time. Relying on 'usually' is what causes most issues in OpenGL titles.

ThyReaper avatar Sep 27 '18 06:09 ThyReaper