From a1bdb544dbaa6520f265be73a2710a5c5b82668d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 25 Nov 2015 01:05:55 -0800 Subject: [PATCH] Avoid an unnecessary string copy --- apps/openmw/mwsound/openal_output.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwsound/openal_output.cpp b/apps/openmw/mwsound/openal_output.cpp index 33202ba741..bafd272af6 100644 --- a/apps/openmw/mwsound/openal_output.cpp +++ b/apps/openmw/mwsound/openal_output.cpp @@ -773,14 +773,16 @@ Sound_Handle OpenAL_Output::loadSound(const std::string &fname) DecoderPtr decoder = mManager.getDecoder(); // Workaround: Bethesda at some point converted some of the files to mp3, but the references were kept as .wav. - std::string file = fname; - if (!decoder->mResourceMgr->exists(file)) + if(decoder->mResourceMgr->exists(fname)) + decoder->open(fname); + else { + std::string file = fname; std::string::size_type pos = file.rfind('.'); if(pos != std::string::npos) file = file.substr(0, pos)+".mp3"; + decoder->open(file); } - decoder->open(file); std::vector data; ChannelConfig chans;