Skip to content

Comments

added Caching Mouse Coordinates to reduce redundant calls#4228

Closed
Chewbakka-Wakka wants to merge 3 commits intoWarzone2100:masterfrom
Chewbakka-Wakka:perf
Closed

added Caching Mouse Coordinates to reduce redundant calls#4228
Chewbakka-Wakka wants to merge 3 commits intoWarzone2100:masterfrom
Chewbakka-Wakka:perf

Conversation

@Chewbakka-Wakka
Copy link
Contributor

Reduces redundant calls, by Caching of mouseX() and mouseY() at the start of processMouseClickInput

Why do?
mouseX() and mouseY() functions are called multiple times per frame, and each call recomputes the mouse coordinates.

Note on explicit assignment to help make intent clearer.

Some comments re-shuffled.

held off on changing mousePos -> Vector2i. Seen elsewhere though.

@Chewbakka-Wakka
Copy link
Contributor Author

mouseInBox may be another candidate

@past-due
Copy link
Member

Fortunately, mouseX() and mouseY() already return cached coordinates. (But good instinct to check for areas where caching could benefit.)

Also, in the future, please try to avoid unrelated changes - such as to whitespace or formatting - when opening a PR. It makes it harder to review and merge.

@past-due past-due closed this May 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants