aboutsummaryrefslogtreecommitdiff
path: root/src/sound_openal.cpp
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-05 00:13:10 +0200
committerNer'zhul <nerzhul@users.noreply.github.com>2016-10-05 07:30:32 +0200
commit5f084cd98d7b3326b51320455364337539710efd (patch)
treed66681421b1b1dfa18d1feb3f0a66d5c03e00c86 /src/sound_openal.cpp
parentd4c76258e37337ea585cf24d8e05b50a30fa307d (diff)
downloadminetest-5f084cd98d7b3326b51320455364337539710efd.tar.gz
minetest-5f084cd98d7b3326b51320455364337539710efd.tar.bz2
minetest-5f084cd98d7b3326b51320455364337539710efd.zip
Make some maps unordered to improve performance
* This permit to improve performance on C++11 builds * use some existing typedefs in tools maps * minor code style changes
Diffstat (limited to 'src/sound_openal.cpp')
-rw-r--r--src/sound_openal.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/sound_openal.cpp b/src/sound_openal.cpp
index 1832a0c77..317667f52 100644
--- a/src/sound_openal.cpp
+++ b/src/sound_openal.cpp
@@ -41,9 +41,9 @@ with this program; ifnot, write to the Free Software Foundation, Inc.,
#include "log.h"
#include "util/numeric.h" // myrand()
#include "porting.h"
-#include <map>
#include <vector>
#include <fstream>
+#include "util/cpp11_container.h"
#define BUFFER_SIZE 30000
@@ -271,8 +271,8 @@ private:
ALCdevice *m_device;
ALCcontext *m_context;
int m_next_id;
- std::map<std::string, std::vector<SoundBuffer*> > m_buffers;
- std::map<int, PlayingSound*> m_sounds_playing;
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> > m_buffers;
+ UNORDERED_MAP<int, PlayingSound*> m_sounds_playing;
v3f m_listener_pos;
public:
bool m_is_initialized;
@@ -337,7 +337,7 @@ public:
alcCloseDevice(m_device);
m_device = NULL;
- for (std::map<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
+ for (UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i = m_buffers.begin();
i != m_buffers.end(); ++i) {
for (std::vector<SoundBuffer*>::iterator iter = (*i).second.begin();
iter != (*i).second.end(); ++iter) {
@@ -351,7 +351,7 @@ public:
void addBuffer(const std::string &name, SoundBuffer *buf)
{
- std::map<std::string, std::vector<SoundBuffer*> >::iterator i =
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
m_buffers.find(name);
if(i != m_buffers.end()){
i->second.push_back(buf);
@@ -365,7 +365,7 @@ public:
SoundBuffer* getBuffer(const std::string &name)
{
- std::map<std::string, std::vector<SoundBuffer*> >::iterator i =
+ UNORDERED_MAP<std::string, std::vector<SoundBuffer*> >::iterator i =
m_buffers.find(name);
if(i == m_buffers.end())
return NULL;
@@ -443,8 +443,7 @@ public:
void deleteSound(int id)
{
- std::map<int, PlayingSound*>::iterator i =
- m_sounds_playing.find(id);
+ UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
if(i == m_sounds_playing.end())
return;
PlayingSound *sound = i->second;
@@ -484,10 +483,8 @@ public:
<<m_sounds_playing.size()<<" playing sounds, "
<<m_buffers.size()<<" sound names loaded"<<std::endl;
std::set<int> del_list;
- for(std::map<int, PlayingSound*>::iterator
- i = m_sounds_playing.begin();
- i != m_sounds_playing.end(); ++i)
- {
+ for(UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.begin();
+ i != m_sounds_playing.end(); ++i) {
int id = i->first;
PlayingSound *sound = i->second;
// If not playing, remove it
@@ -583,9 +580,8 @@ public:
}
void updateSoundPosition(int id, v3f pos)
{
- std::map<int, PlayingSound*>::iterator i =
- m_sounds_playing.find(id);
- if(i == m_sounds_playing.end())
+ UNORDERED_MAP<int, PlayingSound*>::iterator i = m_sounds_playing.find(id);
+ if (i == m_sounds_playing.end())
return;
PlayingSound *sound = i->second;