From d406ac994b8092c5bd2dc32eda1a2eafbf95a30c Mon Sep 17 00:00:00 2001 From: Craig Robbins Date: Fri, 21 Nov 2014 14:43:29 +1000 Subject: Optimise functions from CNodeDefManager and VoxelManipulator CNodeDefManager::get() VoxelManipulator::addArea() --- src/voxel.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/voxel.h') diff --git a/src/voxel.h b/src/voxel.h index 033ad3e45..53b6edbc7 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -80,7 +80,7 @@ public: Modifying methods */ - void addArea(VoxelArea &a) + void addArea(const VoxelArea &a) { if(getExtent() == v3s16(0,0,0)) { @@ -94,7 +94,7 @@ public: if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y; if(a.MaxEdge.Z > MaxEdge.Z) MaxEdge.Z = a.MaxEdge.Z; } - void addPoint(v3s16 p) + void addPoint(const v3s16 &p) { if(getExtent() == v3s16(0,0,0)) { @@ -111,7 +111,7 @@ public: } // Pad with d nodes - void pad(v3s16 d) + void pad(const v3s16 &d) { MinEdge -= d; MaxEdge += d; @@ -366,7 +366,8 @@ public: */ MapNode getNode(v3s16 p) { - addArea(p); + VoxelArea voxel_area(p); + addArea(voxel_area); if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) { @@ -383,7 +384,8 @@ public: } MapNode getNodeNoEx(v3s16 p) { - addArea(p); + VoxelArea voxel_area(p); + addArea(voxel_area); if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) { @@ -417,7 +419,8 @@ public: } MapNode & getNodeRef(v3s16 p) { - addArea(p); + VoxelArea voxel_area(p); + addArea(voxel_area); if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA) { /*dstream<<"EXCEPT: VoxelManipulator::getNode(): " @@ -432,7 +435,8 @@ public: } void setNode(v3s16 p, const MapNode &n) { - addArea(p); + VoxelArea voxel_area(p); + addArea(voxel_area); m_data[m_area.index(p)] = n; m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA; @@ -499,7 +503,7 @@ public: void print(std::ostream &o, INodeDefManager *nodemgr, VoxelPrintMode mode=VOXELPRINT_MATERIAL); - void addArea(VoxelArea area); + void addArea(const VoxelArea &area); /* Copy data and set flags to 0 -- cgit v1.2.3