summaryrefslogtreecommitdiff
path: root/src/mapnode.cpp
diff options
context:
space:
mode:
authorCraig Robbins <kde.psych@gmail.com>2014-11-20 13:36:58 +1000
committerCraig Robbins <kde.psych@gmail.com>2014-11-21 14:56:45 +1000
commitea404979e16ce769c640266039ca3d696189f9d1 (patch)
treeeeb97c50f04418690983bc08fcb211fe531fee5b /src/mapnode.cpp
parentfcdb1a8fc2de2a3928a4be1e6070da7281327e06 (diff)
downloadminetest-ea404979e16ce769c640266039ca3d696189f9d1.tar.gz
minetest-ea404979e16ce769c640266039ca3d696189f9d1.tar.bz2
minetest-ea404979e16ce769c640266039ca3d696189f9d1.zip
Optimise getTileInfo()
getTileInfo() ~1.5x faster getSmoothLight ~2.0x faster
Diffstat (limited to 'src/mapnode.cpp')
-rw-r--r--src/mapnode.cpp20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/mapnode.cpp b/src/mapnode.cpp
index 786224240..fbf0ac8c9 100644
--- a/src/mapnode.cpp
+++ b/src/mapnode.cpp
@@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serialization.h" // For ser_ver_supported
#include "util/serialize.h"
#include "log.h"
+#include "util/numeric.h"
#include <string>
#include <sstream>
@@ -77,19 +78,14 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
- u8 light = 0;
+
+ u8 light;
if(f.param_type == CPT_LIGHT)
- {
- if(bank == LIGHTBANK_DAY)
- light = param1 & 0x0f;
- else if(bank == LIGHTBANK_NIGHT)
- light = (param1>>4)&0x0f;
- else
- assert(0);
- }
- if(f.light_source > light)
- light = f.light_source;
- return light;
+ light = bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
+ else
+ light = 0;
+
+ return MYMAX(f.light_source, light);
}
bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const