From a0ac69088185b642f9f1ce7c652b7ab082af2970 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 21:58:08 -0500 Subject: [PATCH] perf: cache the return value of `IsX11()` (#46427) * perf: cache the return value of IsX11() Co-authored-by: Charles Kerr * fix: mark as nodiscard for those who call, but mark as maybe_unused for Windows Co-authored-by: Charles Kerr --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- 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 0154e2ad7175..b1ec2b740bd8 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 {