Small Optimization
All checks were successful
EnergonRelics/pipeline/head This commit looks good

This commit is contained in:
TheBrokenRail 2020-08-20 21:21:35 -04:00
parent c484e6d78a
commit c095f7da28

View File

@ -47,6 +47,8 @@ public class EnergyTicker {
NetworkComponent.getInstance((ServerWorld) world).clearCache();
world.getProfiler().push("startTick");
List<EnergyTickable> started = new ArrayList<>();
List<EnergyTickable> temp = new ArrayList<>(scheduled);
@ -54,7 +56,7 @@ public class EnergyTicker {
while (!temp.isEmpty()) {
for (EnergyTickable tickable : temp) {
if (!started.contains(tickable)) {
world.getProfiler().push(() -> tickable.getID() + " startTick");
world.getProfiler().push(tickable::getID);
temp2.addAll(tickable.startTick());
started.add(tickable);
@ -62,8 +64,10 @@ public class EnergyTicker {
world.getProfiler().pop();
}
}
temp.clear();
temp.addAll(temp2);
List<EnergyTickable> temp3 = temp;
temp = temp2;
temp2 = temp3;
temp2.clear();
}
@ -73,8 +77,12 @@ public class EnergyTicker {
Collections.shuffle(started, world.random);
world.getProfiler().pop();
world.getProfiler().pop();
world.getProfiler().push("logicTick");
for (EnergyTickable tickable : started) {
world.getProfiler().push(() -> tickable.getID() + " logicTick");
world.getProfiler().push(tickable::getID);
tickable.logicTick();
@ -82,6 +90,8 @@ public class EnergyTicker {
}
world.getProfiler().pop();
world.getProfiler().pop();
}
scheduled.clear();