Potential or partial solution to #179: remove ItemStack::copy.

From my own profiling (which unfortunately I don't have a copy of) of a
situation which involved a single chicken on a hopper attached to a
diamond chest, I noticed that there was a significant slowdown related
to IronChests's item handler.

Specifically (and perhaps exacerbated by the hopper's functionality)
every time an item was "inserted", capability events would be fired and
responded to by a number of mods, resulting in slowdown. This was
compounded as it happened continuously every time it tried to insert the
egg for every single slot.

This seems to be caused by the ItemStack copy in both of the main
inventory handlers.

Looking at their Vanilla equivalents, there doesn't appear to be any
canonical reason for this (as Vanilla does not copy), and it appears as
though it is to be expected that `insertItem` will modify your itemstack
in some way.
This commit is contained in:
Jon McManus 2019-07-19 19:06:27 +10:00
parent 0620ea0d8a
commit 4be7008884
2 changed files with 0 additions and 2 deletions

View File

@ -42,7 +42,6 @@ public class ICChestInventoryHandler implements IItemHandlerModifiable
{ {
if (stack.isEmpty()) if (stack.isEmpty())
return stack; return stack;
stack = stack.copy();
if (!inv.isItemValidForSlot(slot, stack)) if (!inv.isItemValidForSlot(slot, stack))
return stack; return stack;

View File

@ -42,7 +42,6 @@ public class ICShulkerInventoryHandler implements IItemHandlerModifiable
{ {
if (stack.isEmpty()) if (stack.isEmpty())
return stack; return stack;
stack = stack.copy();
if (!inv.isItemValidForSlot(slot, stack)) if (!inv.isItemValidForSlot(slot, stack))
return stack; return stack;