glfw: dont call getError unless we need to #159

Merged
leecannon merged 1 commit from dont_check_errors into main 2022-02-09 02:57:20 +00:00
leecannon commented 2022-02-08 02:00:16 +00:00 (Migrated from github.com)

A large chunk of glfw functions inform us of success using their return values, that means that calling getError is unnecessary in those cases.

The cost of getError (for the non-error case) is more than the single branch checking the return value:

  1. call to glfwGetError
    1. check description pointer
    2. platform tls lookup
    3. check error is not GLFW_NO_ERROR
  2. switch from int to error in convertError
  • By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
A large chunk of glfw functions inform us of success using their return values, that means that calling `getError` is unnecessary in those cases. The cost of `getError` (for the non-error case) is more than the single branch checking the return value: 1. call to `glfwGetError` 1. check `description` pointer 2. platform tls lookup 3. check error is not `GLFW_NO_ERROR` 2. switch from int to error in `convertError` - [X] By selecting this checkbox, I agree to license my contributions to this project under the license(s) described in the LICENSE file, and I have the right to do so or have received permission to do so by an employer or client I am producing work for whom has this right.
emidoots (Migrated from github.com) approved these changes 2022-02-09 02:57:15 +00:00
emidoots (Migrated from github.com) left a comment

Thanks so much for sending this! Great idea

Thanks so much for sending this! Great idea
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
hexops/mach!159
No description provided.