Merge pull request #2486 from cuberite/clientPerformance
Fixed wrong assumtion regarding RemoveClient
This commit is contained in:
commit
7c884df26c
@ -1885,7 +1885,11 @@ bool cChunk::AddClient(cClientHandle * a_Client)
|
|||||||
|
|
||||||
void cChunk::RemoveClient(cClientHandle * a_Client)
|
void cChunk::RemoveClient(cClientHandle * a_Client)
|
||||||
{
|
{
|
||||||
m_LoadedByClient.erase(std::remove(m_LoadedByClient.begin(), m_LoadedByClient.end(), a_Client));
|
auto itr = std::remove(m_LoadedByClient.begin(), m_LoadedByClient.end(), a_Client);
|
||||||
|
// We should always remove at most one client.
|
||||||
|
ASSERT(std::distance(itr, m_LoadedByClient.end()) <= 1);
|
||||||
|
// Note: itr can equal m_LoadedByClient.end()
|
||||||
|
m_LoadedByClient.erase(itr, m_LoadedByClient.end());
|
||||||
|
|
||||||
if (!a_Client->IsDestroyed())
|
if (!a_Client->IsDestroyed())
|
||||||
{
|
{
|
||||||
|
@ -441,9 +441,7 @@ public:
|
|||||||
// Makes a copy of the list
|
// Makes a copy of the list
|
||||||
cClientHandleList GetAllClients(void) const
|
cClientHandleList GetAllClients(void) const
|
||||||
{
|
{
|
||||||
cClientHandleList copy;
|
return cClientHandleList(m_LoadedByClient.begin(), m_LoadedByClient.end());
|
||||||
std::copy(m_LoadedByClient.begin(), m_LoadedByClient.end(), std::back_inserter(copy));
|
|
||||||
return copy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user