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 <charles@charleskerr.com>
This commit is contained in:
trop[bot] 2025-03-29 08:12:04 -05:00 committed by GitHub
parent b51d9976d0
commit a842911215
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,13 +27,8 @@ base::WeakPtr<Notification> NotificationPresenter::CreateNotification(
} }
void NotificationPresenter::RemoveNotification(Notification* notification) { void NotificationPresenter::RemoveNotification(Notification* notification) {
auto it = notifications_.find(notification); if (const auto nh = notifications_.extract(notification))
if (it == notifications_.end()) { delete nh.value();
return;
}
notifications_.erase(notification);
delete notification;
} }
void NotificationPresenter::CloseNotificationWithId( void NotificationPresenter::CloseNotificationWithId(