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

* perf: cache the return value of IsX11()

* fix: mark as nodiscard for those who call, but mark as maybe_unused for Windows
This commit is contained in:
Charles Kerr 2025-04-01 15:28:01 -05:00 committed by GitHub
parent c02e5bc72c
commit 36e233797c
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 #endif
[[maybe_unused]] bool IsX11() { [[maybe_unused, nodiscard]] bool IsX11() {
return ui::OzonePlatform::GetInstance() static const bool is_x11 = ui::OzonePlatform::GetInstance()
->GetPlatformProperties() ->GetPlatformProperties()
.electron_can_call_x11; .electron_can_call_x11;
return is_x11;
} }
class NativeWindowClientView : public views::ClientView { class NativeWindowClientView : public views::ClientView {