Skip to content
Permalink
Browse files

AudioCommon: Use emplace_back instead of push_back in GetSoundBackends()

Constructs the strings directly within the container instead of
performing a construction, then a copy.

The reasoning is that the BACKEND_* strings are const char arrays, so
the push_back code is equivalent to:

push_back(std::string(BACKEND_WHATEVER)) instead of forwarding the
arguments to a constructed instance directly in the container.
  • Loading branch information...
lioncash committed May 31, 2019
1 parent 1a56e9d commit 15397e2a8909eb226e169d496852b6e5625fc4fb
Showing with 8 additions and 8 deletions.
  1. +8 −8 Source/Core/AudioCommon/AudioCommon.cpp
@@ -99,20 +99,20 @@ std::vector<std::string> GetSoundBackends()
{
std::vector<std::string> backends;

backends.push_back(BACKEND_NULLSOUND);
backends.push_back(BACKEND_CUBEB);
backends.emplace_back(BACKEND_NULLSOUND);
backends.emplace_back(BACKEND_CUBEB);
if (XAudio2_7::isValid() || XAudio2::isValid())
backends.push_back(BACKEND_XAUDIO2);
backends.emplace_back(BACKEND_XAUDIO2);
if (AlsaSound::isValid())
backends.push_back(BACKEND_ALSA);
backends.emplace_back(BACKEND_ALSA);
if (PulseAudio::isValid())
backends.push_back(BACKEND_PULSEAUDIO);
backends.emplace_back(BACKEND_PULSEAUDIO);
if (OpenALStream::isValid())
backends.push_back(BACKEND_OPENAL);
backends.emplace_back(BACKEND_OPENAL);
if (OpenSLESStream::isValid())
backends.push_back(BACKEND_OPENSLES);
backends.emplace_back(BACKEND_OPENSLES);
if (WASAPIStream::isValid())
backends.push_back(BACKEND_WASAPI);
backends.emplace_back(BACKEND_WASAPI);

return backends;
}

0 comments on commit 15397e2

Please sign in to comment.
You can’t perform that action at this time.