MapBlock::actuallyUpdateDayNightDiff(): little performance optimization
authorLoic Blot <loic.blot@unix-experience.fr>
Wed, 26 Jul 2017 21:50:53 +0000 (23:50 +0200)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Thu, 27 Jul 2017 05:56:48 +0000 (07:56 +0200)
don't check isLightDayNightEq if checked on previous node

src/mapblock.cpp

index f52a5ee3fabdf488cd65e84f38a24e5bebf378a2..d94955a3b8121c88f6bb4d27bc5919d8efe7c577 100644 (file)
@@ -366,12 +366,19 @@ void MapBlock::actuallyUpdateDayNightDiff()
        /*
                Check if any lighting value differs
        */
+
+       MapNode previous_n;
        for (u32 i = 0; i < nodecount; i++) {
-               MapNode &n = data[i];
+               MapNode n = data[i];
+
+               // If node is identical to previous node, don't verify if it differs
+               if (n == previous_n)
+                       continue;
 
                differs = !n.isLightDayNightEq(nodemgr);
                if (differs)
                        break;
+               previous_n = n;
        }
 
        /*