From c4af7b3f5cb9a24b48709fcabd21a3cceb2a43c5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Nov 2022 08:55:30 -0500 Subject: host1x/syncpoint_manager: Pass DeregisterAction() handle as const-ref The handle is only compared against and not modified in any way, so we can pass it by const reference. This also allows us to mark the respective parameters for DeregisterGuestAction() and DeregisterHostAction() as const references as well. --- src/video_core/host1x/syncpoint_manager.cpp | 6 +++--- src/video_core/host1x/syncpoint_manager.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/video_core/host1x/syncpoint_manager.cpp b/src/video_core/host1x/syncpoint_manager.cpp index a44fc83d3..8f23ce527 100644 --- a/src/video_core/host1x/syncpoint_manager.cpp +++ b/src/video_core/host1x/syncpoint_manager.cpp @@ -34,7 +34,7 @@ SyncpointManager::ActionHandle SyncpointManager::RegisterAction( } void SyncpointManager::DeregisterAction(std::list& action_storage, - ActionHandle& handle) { + const ActionHandle& handle) { std::unique_lock lk(guard); // We want to ensure the iterator still exists prior to erasing it @@ -49,11 +49,11 @@ void SyncpointManager::DeregisterAction(std::list& action_stor } } -void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle) { +void SyncpointManager::DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle) { DeregisterAction(guest_action_storage[syncpoint_id], handle); } -void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle) { +void SyncpointManager::DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle) { DeregisterAction(host_action_storage[syncpoint_id], handle); } diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h index 50a264e23..feafc926e 100644 --- a/src/video_core/host1x/syncpoint_manager.h +++ b/src/video_core/host1x/syncpoint_manager.h @@ -48,9 +48,9 @@ public: expected_value, std::move(func)); } - void DeregisterGuestAction(u32 syncpoint_id, ActionHandle& handle); + void DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle); - void DeregisterHostAction(u32 syncpoint_id, ActionHandle& handle); + void DeregisterHostAction(u32 syncpoint_id, const ActionHandle& handle); void IncrementGuest(u32 syncpoint_id); @@ -76,7 +76,7 @@ private: std::list& action_storage, u32 expected_value, std::function&& action); - void DeregisterAction(std::list& action_storage, ActionHandle& handle); + void DeregisterAction(std::list& action_storage, const ActionHandle& handle); void Wait(std::atomic& syncpoint, std::condition_variable& wait_cv, u32 expected_value); -- cgit v1.2.3 From b6d93b2c778133819aebb2baf6083a1ba0440891 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 29 Nov 2022 08:58:47 -0500 Subject: host1x/syncpoint_manager: Eliminate unnecessary std::function construction We can just pass the function object through, and if it's a valid function, then it will automatically be converted. --- src/video_core/host1x/syncpoint_manager.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/video_core/host1x/syncpoint_manager.h b/src/video_core/host1x/syncpoint_manager.h index feafc926e..847ed20c8 100644 --- a/src/video_core/host1x/syncpoint_manager.h +++ b/src/video_core/host1x/syncpoint_manager.h @@ -36,16 +36,14 @@ public: template ActionHandle RegisterGuestAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function func(action); return RegisterAction(syncpoints_guest[syncpoint_id], guest_action_storage[syncpoint_id], - expected_value, std::move(func)); + expected_value, std::move(action)); } template ActionHandle RegisterHostAction(u32 syncpoint_id, u32 expected_value, Func&& action) { - std::function func(action); return RegisterAction(syncpoints_host[syncpoint_id], host_action_storage[syncpoint_id], - expected_value, std::move(func)); + expected_value, std::move(action)); } void DeregisterGuestAction(u32 syncpoint_id, const ActionHandle& handle); -- cgit v1.2.3