From f3d7a9043d2a265529000611ce1f295e6e3249cf Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 1 Apr 2025 17:55:25 -0500 Subject: [PATCH] perf: cache the return value of `IsX11()` (#46425) * 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 d9dcc4f72712..f3cae134b50e 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 {