Skip to content

Commit

Permalink
AudioCommon: Use emplace_back instead of push_back in GetSoundBackends()
Browse files Browse the repository at this point in the history
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 15397e2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Source/Core/AudioCommon/AudioCommon.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 15397e2

Please sign in to comment.