From dd168b0e8b0b814a9e82d7941dbd0137fe09beb9 Mon Sep 17 00:00:00 2001 From: tycho Date: Wed, 16 Sep 2015 17:04:05 +0100 Subject: Removed a significant performance issue. Iterating through the list of clients in chunks was taking up a significant amount of time with larger numbers of clients due to processor stalls. Changing the data structure to a vector fixed the issue. --- src/Chunk.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/Chunk.h') diff --git a/src/Chunk.h b/src/Chunk.h index fd9ea0b0c..683965c62 100644 --- a/src/Chunk.h +++ b/src/Chunk.h @@ -439,7 +439,12 @@ public: void SetAlwaysTicked(bool a_AlwaysTicked); // Makes a copy of the list - cClientHandleList GetAllClients(void) const {return m_LoadedByClient; } + cClientHandleList GetAllClients(void) const + { + cClientHandleList copy; + std::copy(m_LoadedByClient.begin(), m_LoadedByClient.end(), std::back_inserter(copy)); + return copy; + } private: @@ -479,9 +484,9 @@ private: sSetBlockQueueVector m_SetBlockQueue; ///< Block changes that are queued to a specific tick // A critical section is not needed, because all chunk access is protected by its parent ChunkMap's csLayers - cClientHandleList m_LoadedByClient; - cEntityList m_Entities; - cBlockEntityList m_BlockEntities; + std::vector m_LoadedByClient; + cEntityList m_Entities; + cBlockEntityList m_BlockEntities; /** Number of times the chunk has been requested to stay (by various cChunkStay objects); if zero, the chunk can be unloaded */ int m_StayCount; -- cgit v1.2.3