From a842911215e0fc8ed7742ebfa186be8f738d85e2 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Sat, 29 Mar 2025 08:12:04 -0500 Subject: [PATCH] perf: avoid a double-map lookup in `NotificationPresenter::RemoveNotification()` (#46356) perf: avoid a double-map lokup in NotificationPresenter::RemoveNotification() Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr --- shell/browser/notifications/notification_presenter.cc | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/shell/browser/notifications/notification_presenter.cc b/shell/browser/notifications/notification_presenter.cc index 16ac82a36828..a996dba971cc 100644 --- a/shell/browser/notifications/notification_presenter.cc +++ b/shell/browser/notifications/notification_presenter.cc @@ -27,13 +27,8 @@ base::WeakPtr NotificationPresenter::CreateNotification( } void NotificationPresenter::RemoveNotification(Notification* notification) { - auto it = notifications_.find(notification); - if (it == notifications_.end()) { - return; - } - - notifications_.erase(notification); - delete notification; + if (const auto nh = notifications_.extract(notification)) + delete nh.value(); } void NotificationPresenter::CloseNotificationWithId(