From 2066655aae2022384fc12a10c04dccfd2996f0ac Mon Sep 17 00:00:00 2001 From: Loic Blot Date: Wed, 4 Mar 2015 16:30:24 +0100 Subject: ClientInterface::getClientIDs doesn't need a std::list. Use a std::vector for better perfs --- src/clientiface.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/clientiface.cpp') diff --git a/src/clientiface.cpp b/src/clientiface.cpp index 6180cf5da..126979897 100644 --- a/src/clientiface.cpp +++ b/src/clientiface.cpp @@ -560,9 +560,9 @@ ClientInterface::~ClientInterface() } } -std::list ClientInterface::getClientIDs(ClientState min_state) +std::vector ClientInterface::getClientIDs(ClientState min_state) { - std::list reply; + std::vector reply; JMutexAutoLock clientslock(m_clients_mutex); for(std::map::iterator @@ -596,20 +596,22 @@ void ClientInterface::UpdatePlayerList() { if (m_env != NULL) { - std::list clients = getClientIDs(); + std::vector clients = getClientIDs(); m_clients_names.clear(); if(!clients.empty()) infostream<<"Players:"<::iterator + + for(std::vector::iterator i = clients.begin(); - i != clients.end(); ++i) - { + i != clients.end(); ++i) { Player *player = m_env->getPlayer(*i); - if(player==NULL) + + if (player == NULL) continue; - infostream<<"* "<getName()<<"\t"; + + infostream << "* " << player->getName() << "\t"; { JMutexAutoLock clientslock(m_clients_mutex); @@ -617,6 +619,7 @@ void ClientInterface::UpdatePlayerList() if(client != NULL) client->PrintInfo(infostream); } + m_clients_names.push_back(player->getName()); } } -- cgit v1.2.3