From 6048985cc842af10756ec8cd9fd3106accc5070a Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Thu, 3 Apr 2025 18:41:44 -0500 Subject: [PATCH] perf: avoid redundant call to virtual methods GetProcess() and GetID() (#46444) Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/api/electron_api_web_contents.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/shell/browser/api/electron_api_web_contents.cc b/shell/browser/api/electron_api_web_contents.cc index 0f22bb8655c4..4fc3ebbfc5b2 100644 --- a/shell/browser/api/electron_api_web_contents.cc +++ b/shell/browser/api/electron_api_web_contents.cc @@ -1788,19 +1788,18 @@ void WebContents::FrameDeleted(content::FrameTreeNodeId frame_tree_node_id) { } void WebContents::RenderViewDeleted(content::RenderViewHost* render_view_host) { + const auto id = render_view_host->GetProcess()->GetID().GetUnsafeValue(); // This event is necessary for tracking any states with respect to // intermediate render view hosts aka speculative render view hosts. Currently // used by object-registry.js to ref count remote objects. - Emit("render-view-deleted", - render_view_host->GetProcess()->GetID().GetUnsafeValue()); + Emit("render-view-deleted", id); if (web_contents()->GetRenderViewHost() == render_view_host) { // When the RVH that has been deleted is the current RVH it means that the // the web contents are being closed. This is communicated by this event. // Currently tracked by guest-window-manager.ts to destroy the // BrowserWindow. - Emit("current-render-view-deleted", - render_view_host->GetProcess()->GetID().GetUnsafeValue()); + Emit("current-render-view-deleted", id); } }