aboutsummaryrefslogtreecommitdiffstats
path: root/alc/backends/alsa.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2022-12-15 22:35:52 -0800
committerChris Robinson <[email protected]>2022-12-15 22:35:52 -0800
commit8b806c07d716db41e0a463d455cf1a913b933a0f (patch)
tree7e4516e8f6e79abbbd06dff84ad2a1d0a4f161a6 /alc/backends/alsa.cpp
parent2bd11bafa4b36977c9d467d5e2d735a8eba1b336 (diff)
Avoid extraneous temporaries when filling vectors
Diffstat (limited to 'alc/backends/alsa.cpp')
-rw-r--r--alc/backends/alsa.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/alc/backends/alsa.cpp b/alc/backends/alsa.cpp
index 85f1824b..e495a34d 100644
--- a/alc/backends/alsa.cpp
+++ b/alc/backends/alsa.cpp
@@ -241,6 +241,11 @@ SwParamsPtr CreateSwParams()
struct DevMap {
std::string name;
std::string device_name;
+
+ template<typename T, typename U>
+ DevMap(T&& name_, U&& devname)
+ : name{std::forward<T>(name_)}, device_name{std::forward<U>(devname)}
+ { }
};
al::vector<DevMap> PlaybackDevices;
@@ -264,7 +269,7 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
auto defname = ConfigValueStr(nullptr, "alsa",
(stream == SND_PCM_STREAM_PLAYBACK) ? "device" : "capture");
- devlist.emplace_back(DevMap{alsaDevice, defname ? defname->c_str() : "default"});
+ devlist.emplace_back(alsaDevice, defname ? defname->c_str() : "default");
if(auto customdevs = ConfigValueStr(nullptr, "alsa",
(stream == SND_PCM_STREAM_PLAYBACK) ? "custom-devices" : "custom-captures"))
@@ -283,8 +288,8 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
}
else
{
- devlist.emplace_back(DevMap{customdevs->substr(curpos, seppos-curpos),
- customdevs->substr(seppos+1, nextpos-seppos-1)});
+ devlist.emplace_back(customdevs->substr(curpos, seppos-curpos),
+ customdevs->substr(seppos+1, nextpos-seppos-1));
const auto &entry = devlist.back();
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
}
@@ -367,7 +372,7 @@ al::vector<DevMap> probe_devices(snd_pcm_stream_t stream)
device += ",DEV=";
device += std::to_string(dev);
- devlist.emplace_back(DevMap{std::move(name), std::move(device)});
+ devlist.emplace_back(std::move(name), std::move(device));
const auto &entry = devlist.back();
TRACE("Got device \"%s\", \"%s\"\n", entry.name.c_str(), entry.device_name.c_str());
}