aboutsummaryrefslogtreecommitdiff
path: root/src/client/mesh_generator_thread.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2022-07-31 23:16:40 +0200
committersfan5 <sfan5@live.de>2022-08-02 11:58:26 +0200
commitf22d40975e907d9f0e84b67b21256953333a6cc8 (patch)
tree20001947bf5e64db5a71c426ebb6a413d5e0c1dc /src/client/mesh_generator_thread.cpp
parent4c1ef1b72bfb949b149e6eb75cb7082e31d22b5d (diff)
downloadminetest-f22d40975e907d9f0e84b67b21256953333a6cc8.tar.gz
minetest-f22d40975e907d9f0e84b67b21256953333a6cc8.tar.bz2
minetest-f22d40975e907d9f0e84b67b21256953333a6cc8.zip
Switch MeshUpdateQueue to better data structure
Diffstat (limited to 'src/client/mesh_generator_thread.cpp')
-rw-r--r--src/client/mesh_generator_thread.cpp10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/client/mesh_generator_thread.cpp b/src/client/mesh_generator_thread.cpp
index 9f4d98aac..c1bd7388e 100644
--- a/src/client/mesh_generator_thread.cpp
+++ b/src/client/mesh_generator_thread.cpp
@@ -158,8 +158,7 @@ CachedMapBlockData* MeshUpdateQueue::cacheBlock(Map *map, v3s16 p, UpdateMode mo
size_t *cache_hit_counter)
{
CachedMapBlockData *cached_block = nullptr;
- std::map<v3s16, CachedMapBlockData*>::iterator it =
- m_cache.find(p);
+ auto it = m_cache.find(p);
if (it != m_cache.end()) {
cached_block = it->second;
@@ -193,7 +192,7 @@ CachedMapBlockData* MeshUpdateQueue::cacheBlock(Map *map, v3s16 p, UpdateMode mo
CachedMapBlockData* MeshUpdateQueue::getCachedBlock(const v3s16 &p)
{
- std::map<v3s16, CachedMapBlockData*>::iterator it = m_cache.find(p);
+ auto it = m_cache.find(p);
if (it != m_cache.end()) {
return it->second;
}
@@ -250,12 +249,11 @@ void MeshUpdateQueue::cleanupCache()
int t_now = time(0);
- for (std::map<v3s16, CachedMapBlockData*>::iterator it = m_cache.begin();
- it != m_cache.end(); ) {
+ for (auto it = m_cache.begin(); it != m_cache.end(); ) {
CachedMapBlockData *cached_block = it->second;
if (cached_block->refcount_from_queue == 0 &&
cached_block->last_used_timestamp < t_now - cache_seconds) {
- m_cache.erase(it++);
+ it = m_cache.erase(it);
delete cached_block;
} else {
++it;