From 2baa4a3514589c123f035134a51a2d498bd76d15 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 28 Mar 2025 21:33:11 -0500 Subject: [PATCH] perf: avoid a double-map lookup in `NotificationPresenter::RemoveNotification()` (#46338) perf: avoid a double-map lokup in NotificationPresenter::RemoveNotification() --- 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(