1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

use unordered containers where possible (patch 4 on X)

Also remove some unused parameters/functions
This commit is contained in:
Loic Blot 2016-10-06 19:20:12 +02:00 committed by sfan5
parent b66a5d2f88
commit 155288ee98
13 changed files with 63 additions and 99 deletions

View file

@ -26,8 +26,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "../irr_v3d.h"
#include "../irr_aabb3d.h"
#include "../threading/mutex.h"
#include "cpp11_container.h"
#include <list>
#include <map>
#include <vector>
@ -41,26 +41,10 @@ public:
static std::vector<v3s16> getFacePositions(u16 d);
private:
static void generateFacePosition(u16 d);
static std::map<u16, std::vector<v3s16> > m_cache;
static UNORDERED_MAP<u16, std::vector<v3s16> > m_cache;
static Mutex m_cache_mutex;
};
class IndentationRaiser
{
public:
IndentationRaiser(u16 *indentation)
{
m_indentation = indentation;
(*m_indentation)++;
}
~IndentationRaiser()
{
(*m_indentation)--;
}
private:
u16 *m_indentation;
};
inline s16 getContainerPos(s16 p, s16 d)
{
return (p>=0 ? p : p-d+1) / d;
@ -149,23 +133,6 @@ inline bool isInArea(v3s16 p, v3s16 d)
#define rangelim(d, min, max) ((d) < (min) ? (min) : ((d)>(max)?(max):(d)))
#define myfloor(x) ((x) > 0.0 ? (int)(x) : (int)(x) - 1)
inline v3s16 arealim(v3s16 p, s16 d)
{
if(p.X < 0)
p.X = 0;
if(p.Y < 0)
p.Y = 0;
if(p.Z < 0)
p.Z = 0;
if(p.X > d-1)
p.X = d-1;
if(p.Y > d-1)
p.Y = d-1;
if(p.Z > d-1)
p.Z = d-1;
return p;
}
// The naive swap performs better than the xor version
#define SWAP(t, x, y) do { \
t temp = x; \