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

* perf: cache the return value of IsX11()

Co-authored-by: Charles Kerr <charles@charleskerr.com>

* fix: mark as nodiscard for those who call, but mark as maybe_unused for Windows

Co-authored-by: Charles Kerr <charles@charleskerr.com>

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-04-01 21:58:08 -05:00 committed by GitHub
parent 7299dd1501
commit a0ac690881
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -163,10 +163,11 @@ gfx::Size WindowSizeToContentSizeBuggy(HWND hwnd, const gfx::Size& size) {
#endif
[[maybe_unused]] bool IsX11() {
return ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.electron_can_call_x11;
[[maybe_unused, nodiscard]] bool IsX11() {
static const bool is_x11 = ui::OzonePlatform::GetInstance()
->GetPlatformProperties()
.electron_can_call_x11;
return is_x11;
}
class NativeWindowClientView : public views::ClientView {