From 93bd630d40b410efa1d544022e4192d4113eb1a5 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 11 Sep 2018 21:36:07 -0400 Subject: [PATCH] audio_core/sink_details: Change std::string parameter into std::string_view The given string is only ever used for lookup and comparison, so we can just utilize a non-owning view to string data here --- src/audio_core/sink_details.cpp | 2 +- src/audio_core/sink_details.h | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/audio_core/sink_details.cpp b/src/audio_core/sink_details.cpp index 2bac7e3e1..b85e56e51 100644 --- a/src/audio_core/sink_details.cpp +++ b/src/audio_core/sink_details.cpp @@ -30,7 +30,7 @@ const std::vector g_sink_details = { [] { return std::vector{"null"}; }}, }; -const SinkDetails& GetSinkDetails(std::string sink_id) { +const SinkDetails& GetSinkDetails(std::string_view sink_id) { auto iter = std::find_if(g_sink_details.begin(), g_sink_details.end(), [sink_id](const auto& sink_detail) { return sink_detail.id == sink_id; }); diff --git a/src/audio_core/sink_details.h b/src/audio_core/sink_details.h index e7b3a4b01..abad0f9a5 100644 --- a/src/audio_core/sink_details.h +++ b/src/audio_core/sink_details.h @@ -6,6 +6,8 @@ #include #include +#include +#include #include #include @@ -30,6 +32,6 @@ struct SinkDetails { extern const std::vector g_sink_details; -const SinkDetails& GetSinkDetails(std::string sink_id); +const SinkDetails& GetSinkDetails(std::string_view sink_id); } // namespace AudioCore