1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Use more unordered_maps to improve performance in c++11 builds

This commit is contained in:
Loic Blot 2016-10-06 08:48:20 +02:00 committed by sfan5
parent 997fc59c7e
commit 667975fe3a
9 changed files with 22 additions and 27 deletions

View file

@ -794,7 +794,7 @@ void Server::AsyncRunStep(bool initial_step)
// Key = object id
// Value = data sent by object
std::map<u16, std::vector<ActiveObjectMessage>* > buffered_messages;
UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* > buffered_messages;
// Get active object messages from environment
for(;;) {
@ -803,7 +803,7 @@ void Server::AsyncRunStep(bool initial_step)
break;
std::vector<ActiveObjectMessage>* message_list = NULL;
std::map<u16, std::vector<ActiveObjectMessage>* >::iterator n;
UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator n;
n = buffered_messages.find(aom.id);
if (n == buffered_messages.end()) {
message_list = new std::vector<ActiveObjectMessage>;
@ -824,7 +824,7 @@ void Server::AsyncRunStep(bool initial_step)
std::string reliable_data;
std::string unreliable_data;
// Go through all objects in message buffer
for (std::map<u16, std::vector<ActiveObjectMessage>* >::iterator
for (UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator
j = buffered_messages.begin();
j != buffered_messages.end(); ++j) {
// If object is not known by client, skip it
@ -868,7 +868,7 @@ void Server::AsyncRunStep(bool initial_step)
m_clients.unlock();
// Clear buffered_messages
for(std::map<u16, std::vector<ActiveObjectMessage>* >::iterator
for(UNORDERED_MAP<u16, std::vector<ActiveObjectMessage>* >::iterator
i = buffered_messages.begin();
i != buffered_messages.end(); ++i) {
delete i->second;