Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: cache the return value of IsX11() #46391

Merged
merged 2 commits into from
Apr 1, 2025
Merged

Conversation

ckerr
Copy link
Member

@ckerr ckerr commented Mar 31, 2025

Description of Change

The return value of IsX11() isn't ever going to change during an Electron session, and it's cheap to cache the return value in a static const bool, so let's do that instead of re-running the test every time the function is called.

Also, add a [[nodiscard]] annotation to indicate that callers should use the return value.

Checklist

Release Notes

Notes: none.

@ckerr ckerr added performance 🏁 semver/patch backwards-compatible bug fixes target/34-x-y PR should also be added to the "34-x-y" branch. target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. labels Mar 31, 2025
@electron-cation electron-cation bot added the new-pr 🌱 PR opened in the last 24 hours label Mar 31, 2025
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened in the last 24 hours label Apr 1, 2025
@ckerr ckerr merged commit 36e2337 into main Apr 1, 2025
59 checks passed
@ckerr ckerr deleted the perf/cache-return-value-of-IsX11 branch April 1, 2025 20:28
@release-clerk
Copy link

release-clerk bot commented Apr 1, 2025

No Release Notes

@trop
Copy link
Contributor

trop bot commented Apr 1, 2025

I have automatically backported this PR to "35-x-y", please check out #46425

@trop trop bot added in-flight/35-x-y and removed target/35-x-y PR should also be added to the "35-x-y" branch. labels Apr 1, 2025
@trop
Copy link
Contributor

trop bot commented Apr 1, 2025

I have automatically backported this PR to "34-x-y", please check out #46426

@trop
Copy link
Contributor

trop bot commented Apr 1, 2025

I have automatically backported this PR to "36-x-y", please check out #46427

@trop trop bot added in-flight/34-x-y in-flight/36-x-y merged/34-x-y PR was merged to the "34-x-y" branch. merged/35-x-y PR was merged to the "35-x-y" branch. and removed target/34-x-y PR should also be added to the "34-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. in-flight/34-x-y in-flight/35-x-y labels Apr 1, 2025
@trop trop bot added merged/36-x-y PR was merged to the "36-x-y" branch. and removed in-flight/36-x-y labels Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged/34-x-y PR was merged to the "34-x-y" branch. merged/35-x-y PR was merged to the "35-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. performance 🏁 semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants