Skip to content

Commit

Permalink
Make craftingList a hash set in DualityInterface
Browse files Browse the repository at this point in the history
Improves pattern lookup times, even though I'm not sure why this check even exist
  • Loading branch information
NotMyWing committed Jun 10, 2024
1 parent 6632344 commit d40b983
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/main/java/appeng/helpers/DualityInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
import appeng.parts.misc.PartInterface;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.AppEngInternalOversizedInventory;
import appeng.tile.inventory.AppEngNetworkInventory;
import appeng.tile.networking.TileCableBus;
import appeng.util.ConfigManager;
Expand All @@ -78,6 +77,7 @@
import de.ellpeck.actuallyadditions.api.tile.IPhantomTile;
import gregtech.api.block.machines.BlockMachine;
import gregtech.api.metatileentity.MetaTileEntity;
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Items;
Expand Down Expand Up @@ -128,7 +128,7 @@ public class DualityInterface implements IGridTickable, IStorageMonitorable, IIn
private final Accessor accessor = new Accessor();
private boolean hasConfig = false;
private int priority;
private List<ICraftingPatternDetails> craftingList = null;
private Set<ICraftingPatternDetails> craftingList = null;
private List<ItemStack> waitingToSend = null;
private IMEInventory<IAEItemStack> destination;
private int isWorking = -1;
Expand Down Expand Up @@ -452,10 +452,13 @@ private void updateCraftingList() {
this.addToCraftingList(this.patterns.getStackInSlot(x));
}
}
try {
this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
} catch (GridAccessException e) {
e.printStackTrace();

if (newPattern || removed) {
try {
this.gridProxy.getGrid().postEvent(new MENetworkCraftingPatternChange(this, this.gridProxy.getNode()));
} catch (GridAccessException e) {
e.printStackTrace();
}
}
}

Expand Down Expand Up @@ -545,7 +548,7 @@ private void addToCraftingList(final ItemStack is) {

if (details != null) {
if (this.craftingList == null) {
this.craftingList = new ArrayList<>();
this.craftingList = new ObjectOpenHashSet<>();
}

this.craftingList.add(details);
Expand Down

0 comments on commit d40b983

Please sign in to comment.