aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorLoic Blot <loic.blot@unix-experience.fr>2016-10-06 19:20:12 +0200
committersfan5 <sfan5@live.de>2016-10-06 22:37:26 +0200
commit155288ee981c70f505526347cb2bcda4df1c8e6b (patch)
tree582095bc50cb60d3dedb9f6a08e908324a3da365 /src/util
parentb66a5d2f8842cc84ae44257dc0ead255e5b0538f (diff)
downloadminetest-155288ee981c70f505526347cb2bcda4df1c8e6b.tar.gz
minetest-155288ee981c70f505526347cb2bcda4df1c8e6b.tar.bz2
minetest-155288ee981c70f505526347cb2bcda4df1c8e6b.zip
use unordered containers where possible (patch 4 on X)
Also remove some unused parameters/functions
Diffstat (limited to 'src/util')
-rw-r--r--src/util/numeric.cpp2
-rw-r--r--src/util/numeric.h37
2 files changed, 3 insertions, 36 deletions
diff --git a/src/util/numeric.cpp b/src/util/numeric.cpp
index 42ebd9022..6a7bfcac9 100644
--- a/src/util/numeric.cpp
+++ b/src/util/numeric.cpp
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <string.h>
#include <iostream>
-std::map<u16, std::vector<v3s16> > FacePositionCache::m_cache;
+UNORDERED_MAP<u16, std::vector<v3s16> > FacePositionCache::m_cache;
Mutex FacePositionCache::m_cache_mutex;
// Calculate the borders of a "d-radius" cube
// TODO: Make it work without mutex and data races, probably thread-local
diff --git a/src/util/numeric.h b/src/util/numeric.h
index 615327864..4cdc254c3 100644
--- a/src/util/numeric.h
+++ b/src/util/numeric.h
@@ -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; \