From 02589809770e749682ef55ada7b02ff5eb54ed66 Mon Sep 17 00:00:00 2001 From: mjk Date: Mon, 22 Mar 2021 13:37:09 +0000 Subject: [PATCH] replace lists with vectors --- .../src/gobject/winrt-toast-notification.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/plugins/windows-notification/api/src/gobject/winrt-toast-notification.cpp b/plugins/windows-notification/api/src/gobject/winrt-toast-notification.cpp index 2ec808e0..e7663e09 100644 --- a/plugins/windows-notification/api/src/gobject/winrt-toast-notification.cpp +++ b/plugins/windows-notification/api/src/gobject/winrt-toast-notification.cpp @@ -2,7 +2,6 @@ #include #include #include -#include #include #include @@ -10,6 +9,12 @@ #include "winrt-event-token-private.h" #include "converter.hpp" +template +inline void erase_if(Cont &c, Pred p) +{ + c.erase(std::remove_if(c.begin(), c.end(), std::move(p)), c.end()); +} + #define WINRT_WINDOWS_UI_NOTIFICATION_TOAST_NOTIFICATION_GET_PRIVATE(obj) \ ((winrtWindowsUINotificationsToastNotificationPrivate*) winrt_windows_ui_notifications_toast_notification_get_instance_private ((winrtWindowsUINotificationsToastNotification*) (obj))) @@ -70,9 +75,9 @@ struct _winrtWindowsUINotificationsToastNotificationPrivate { winrt::Windows::UI::Notifications::ToastNotification data; - std::list>> activated{}; - std::list>> failed{}; - std::list>> dismissed{}; + std::vector>> activated{}; + std::vector>> failed{}; + std::vector>> dismissed{}; }; typedef struct @@ -326,7 +331,7 @@ void winrt_windows_ui_notifications_toast_notification_RemoveActivated(winrtWind winrtWindowsUINotificationsToastNotificationPrivate* priv = WINRT_WINDOWS_UI_NOTIFICATION_TOAST_NOTIFICATION_GET_PRIVATE(self); - priv->notification->activated.remove_if([&](const auto& callback) { + erase_if(priv->notification->activated, [&](const auto& callback) { if (winrt_event_token_get_value(token) == winrt_event_token_get_value(callback->GetToken())) { if (winrt_event_token_operator_bool(callback->GetToken())) @@ -345,7 +350,7 @@ void winrt_windows_ui_notifications_toast_notification_RemoveFailed(winrtWindows winrtWindowsUINotificationsToastNotificationPrivate* priv = WINRT_WINDOWS_UI_NOTIFICATION_TOAST_NOTIFICATION_GET_PRIVATE(self); - priv->notification->failed.remove_if([&](const auto& callback) { + erase_if(priv->notification->failed, [&](const auto& callback) { if (winrt_event_token_get_value(token) == winrt_event_token_get_value(callback->GetToken())) { if (winrt_event_token_operator_bool(callback->GetToken())) @@ -364,7 +369,7 @@ void winrt_windows_ui_notifications_toast_notification_RemoveDismissed(winrtWind winrtWindowsUINotificationsToastNotificationPrivate* priv = WINRT_WINDOWS_UI_NOTIFICATION_TOAST_NOTIFICATION_GET_PRIVATE(self); - priv->notification->dismissed.remove_if([&](const auto& callback) { + erase_if(priv->notification->dismissed, [&](const auto& callback) { if (winrt_event_token_get_value(token) == winrt_event_token_get_value(callback->GetToken())) { if (winrt_event_token_operator_bool(callback->GetToken()))