From ef86454c443ab8bc393d12b1bf289da7e9f2f1bf Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Wed, 1 Jan 2014 03:03:00 -0600 Subject: [PATCH] Speed boost for NBT / AE Items. --- util/item/AEItemStack.java | 10 +++++----- util/item/AESharedNBT.java | 5 +---- util/item/SharedSearchObject.java | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/util/item/AEItemStack.java b/util/item/AEItemStack.java index 6c7b1168..50a6d7a6 100644 --- a/util/item/AEItemStack.java +++ b/util/item/AEItemStack.java @@ -77,7 +77,9 @@ public final class AEItemStack extends AEStack implements IAEItemS def.dspDamage = is.getItemDamageForDisplay(); def.maxDamage = is.getMaxDamage(); - def.tagCompound = (IAETagCompound) AESharedNBT.getSharedTagCompound( is ); + NBTTagCompound tagCompound = is.getTagCompound(); + if ( tagCompound != null ) + def.tagCompound = (IAETagCompound) AESharedNBT.getSharedTagCompound( tagCompound, is ); stackSize = is.stackSize; setCraftable( false ); @@ -88,12 +90,10 @@ public final class AEItemStack extends AEStack implements IAEItemS public static AEItemStack create(Object a) { - if ( a == null ) - return null; - if ( a instanceof IAEItemStack ) - ((IAEItemStack) a).copy(); if ( a instanceof ItemStack ) return new AEItemStack( (ItemStack) a ); + if ( a instanceof IAEItemStack ) + ((IAEItemStack) a).copy(); return null; } diff --git a/util/item/AESharedNBT.java b/util/item/AESharedNBT.java index f42f9308..a19e626a 100644 --- a/util/item/AESharedNBT.java +++ b/util/item/AESharedNBT.java @@ -129,11 +129,8 @@ public class AESharedNBT extends NBTTagCompound implements IAETagCompound /* * Returns an NBT Compound that is used for accelerating comparisons. */ - synchronized public static NBTTagCompound getSharedTagCompound(ItemStack s) + synchronized public static NBTTagCompound getSharedTagCompound(NBTTagCompound tagCompound, ItemStack s) { - NBTTagCompound tagCompound = s.getTagCompound(); - if ( tagCompound == null ) - return null; if ( tagCompound.hasNoTags() ) return null; diff --git a/util/item/SharedSearchObject.java b/util/item/SharedSearchObject.java index 0ee48e89..c203647b 100644 --- a/util/item/SharedSearchObject.java +++ b/util/item/SharedSearchObject.java @@ -1,7 +1,7 @@ package appeng.util.item; -import appeng.util.Platform; import net.minecraft.nbt.NBTTagCompound; +import appeng.util.Platform; public class SharedSearchObject {