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;
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;
}
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;
#include <ctime>
#include <mutex>
+#include <unordered_map>
+#include <unordered_set>
#include "mapblock_mesh.h"
#include "threading/mutex_auto_lock.h"
#include "util/thread.h"
private:
Client *m_client;
std::vector<QueuedMeshUpdate *> m_queue;
- std::set<v3s16> m_urgents;
- std::map<v3s16, CachedMapBlockData *> m_cache;
+ std::unordered_set<v3s16> m_urgents;
+ std::unordered_map<v3s16, CachedMapBlockData *> m_cache;
u64 m_next_cache_cleanup; // milliseconds
std::mutex m_mutex;