From 89ebef65719a95cbd43385efde56d3e83fade290 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 1 Aug 2018 23:50:45 -0400 Subject: sink_details: std::move std::function instances Given std::function is allowed to potentially allocate, these should be std::move'd to prevent potential reallocation (should that ever happen). --- src/audio_core/sink_details.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/audio_core/sink_details.h b/src/audio_core/sink_details.h index aa8aae1a9..4f9027762 100644 --- a/src/audio_core/sink_details.h +++ b/src/audio_core/sink_details.h @@ -6,6 +6,7 @@ #include #include +#include #include namespace AudioCore { @@ -15,7 +16,7 @@ class Sink; struct SinkDetails { SinkDetails(const char* id_, std::function(std::string)> factory_, std::function()> list_devices_) - : id(id_), factory(factory_), list_devices(list_devices_) {} + : id(id_), factory(std::move(factory_)), list_devices(std::move(list_devices_)) {} /// Name for this sink. const char* id; -- cgit v1.2.3 From 2bc4ab395850efa84ba879c7a9bcff5df6768a39 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 1 Aug 2018 23:55:59 -0400 Subject: sink_details: Deduplicate long std::function repetition We can just use type aliases to avoid needing to write the same long type twice --- src/audio_core/sink_details.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/audio_core/sink_details.h b/src/audio_core/sink_details.h index 4f9027762..ea666c554 100644 --- a/src/audio_core/sink_details.h +++ b/src/audio_core/sink_details.h @@ -14,16 +14,18 @@ namespace AudioCore { class Sink; struct SinkDetails { - SinkDetails(const char* id_, std::function(std::string)> factory_, - std::function()> list_devices_) + using FactoryFn = std::function(std::string)>; + using ListDevicesFn = std::function()>; + + SinkDetails(const char* id_, FactoryFn factory_, ListDevicesFn list_devices_) : id(id_), factory(std::move(factory_)), list_devices(std::move(list_devices_)) {} /// Name for this sink. const char* id; /// A method to call to construct an instance of this type of sink. - std::function(std::string device_id)> factory; + FactoryFn factory; /// A method to call to list available devices. - std::function()> list_devices; + ListDevicesFn list_devices; }; extern const std::vector g_sink_details; -- cgit v1.2.3