change lists for sets to increase contains performance

Closes #784
This commit is contained in:
Ellpeck 2017-05-28 00:37:27 +02:00
parent e19c98269f
commit 3b8c81638f
3 changed files with 10 additions and 13 deletions

View file

@ -31,10 +31,10 @@ import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
@ -143,9 +143,9 @@ public class TileEntityLaserRelayEnergy extends TileEntityLaserRelay{
private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate){ private int transferEnergyToReceiverInNeed(EnumFacing from, Network network, int maxTransfer, boolean simulate){
int transmitted = 0; int transmitted = 0;
//Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>(); Set<BlockPos> alreadyChecked = new HashSet<BlockPos>();
List<TileEntityLaserRelayEnergy> relaysThatWork = new ArrayList<TileEntityLaserRelayEnergy>(); Set<TileEntityLaserRelayEnergy> relaysThatWork = new HashSet<TileEntityLaserRelayEnergy>();
int totalReceiverAmount = 0; int totalReceiverAmount = 0;
for(IConnectionPair pair : network.connections){ for(IConnectionPair pair : network.connections){

View file

@ -30,10 +30,10 @@ import net.minecraftforge.fluids.capability.IFluidTankProperties;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{
@ -139,9 +139,9 @@ public class TileEntityLaserRelayFluids extends TileEntityLaserRelay{
private int transferFluidToReceiverInNeed(EnumFacing from, Network network, FluidStack stack, boolean doFill){ private int transferFluidToReceiverInNeed(EnumFacing from, Network network, FluidStack stack, boolean doFill){
int transmitted = 0; int transmitted = 0;
//Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times //Keeps track of all the Laser Relays and Energy Acceptors that have been checked already to make nothing run multiple times
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>(); Set<BlockPos> alreadyChecked = new HashSet<BlockPos>();
List<TileEntityLaserRelayFluids> relaysThatWork = new ArrayList<TileEntityLaserRelayFluids>(); Set<TileEntityLaserRelayFluids> relaysThatWork = new HashSet<TileEntityLaserRelayFluids>();
int totalReceiverAmount = 0; int totalReceiverAmount = 0;
for(IConnectionPair pair : network.connections){ for(IConnectionPair pair : network.connections){

View file

@ -32,10 +32,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler; import net.minecraftforge.items.IItemHandler;
import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig; import org.cyclops.commoncapabilities.capability.itemhandler.SlotlessItemHandlerConfig;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
@ -111,7 +108,7 @@ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public void getItemHandlersInNetwork(Network network, List<GenericItemHandlerInfo> storeList){ public void getItemHandlersInNetwork(Network network, List<GenericItemHandlerInfo> storeList){
//Keeps track of all the Laser Relays and Item Handlers that have been checked already to make nothing run multiple times //Keeps track of all the Laser Relays and Item Handlers that have been checked already to make nothing run multiple times
List<BlockPos> alreadyChecked = new ArrayList<BlockPos>(); Set<BlockPos> alreadyChecked = new HashSet<BlockPos>();
for(IConnectionPair pair : network.connections){ for(IConnectionPair pair : network.connections){
for(BlockPos relay : pair.getPositions()){ for(BlockPos relay : pair.getPositions()){