1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 18:19:55 +00:00

Avoid copying the same Ptr with each iteration

This commit is contained in:
Chris Robinson 2017-09-13 02:47:26 -07:00
parent edfba68eb5
commit 6f57233ba1

View file

@ -1005,11 +1005,14 @@ namespace MWSound
SoundMap::iterator snditer = mActiveSounds.begin();
while(snditer != mActiveSounds.end())
{
MWWorld::ConstPtr ptr = snditer->first;
SoundBufferRefPairList::iterator sndidx = snditer->second.begin();
while(sndidx != snditer->second.end())
{
MWWorld::ConstPtr ptr = snditer->first;
Sound *sound = sndidx->first;
Sound *sound;
Sound_Buffer *sfx;
std::tie(sound, sfx) = *sndidx;
if(!ptr.isEmpty() && sound->getIs3D())
{
const ESM::Position &pos = ptr.getRefData().getPosition();
@ -1031,7 +1034,6 @@ namespace MWSound
mUnderwaterSound = nullptr;
if(sound == mNearWaterSound)
mNearWaterSound = nullptr;
Sound_Buffer *sfx = sndidx->second;
if(sfx->mUses-- == 1)
mUnusedBuffers.push_front(sfx);
sndidx = snditer->second.erase(sndidx);
@ -1045,7 +1047,7 @@ namespace MWSound
}
}
if(snditer->second.empty())
mActiveSounds.erase(snditer++);
snditer = mActiveSounds.erase(snditer);
else
++snditer;
}