From 36e233797c3e2216576c4891328a1354452bb67f Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 1 Apr 2025 15:28:01 -0500 Subject: [PATCH] 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 --- shell/browser/native_window_views.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/shell/browser/native_window_views.cc b/shell/browser/native_window_views.cc index c3bcb4bf4dd4..ae330edc0f28 100644 --- a/shell/browser/native_window_views.cc +++ b/shell/browser/native_window_views.cc @@ -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 {