Skip to content

Commit e8b5b03

Browse files
committed
refactor AudioEngine-Linux
use std::map::insert properly
1 parent 8b48536 commit e8b5b03

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cocos/audio/linux/AudioEngine-linux.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,9 @@ int AudioEngineImpl::preload(const std::string& filePath, std::function<void(boo
320320
}
321321

322322
int id = static_cast<int>(mapChannelInfo.size()) + 1;
323-
if (mapId.find(filePath) == mapId.end())
324-
mapId.insert({filePath, id});
325-
else
326-
id = mapId.at(filePath);
323+
// std::map::insert returns std::pair<iter, bool>
324+
auto pIterBool = mapId.insert({filePath, id});
325+
id = pIterBool.first->second;
327326

328327
auto& chanelInfo = mapChannelInfo[id];
329328
chanelInfo.sound = sound;

0 commit comments

Comments
 (0)