diff options
Diffstat (limited to 'Spigot-Server-Patches/0186-Optimize-ItemStack.isEmpty.patch')
-rw-r--r-- | Spigot-Server-Patches/0186-Optimize-ItemStack.isEmpty.patch | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Spigot-Server-Patches/0186-Optimize-ItemStack.isEmpty.patch b/Spigot-Server-Patches/0186-Optimize-ItemStack.isEmpty.patch new file mode 100644 index 0000000000..157a8417e3 --- /dev/null +++ b/Spigot-Server-Patches/0186-Optimize-ItemStack.isEmpty.patch @@ -0,0 +1,31 @@ +From 43215a4d47506b61a0eafcda2a8e2d579cf7ffdb Mon Sep 17 00:00:00 2001 +From: Aikar <[email protected]> +Date: Wed, 21 Dec 2016 03:48:29 -0500 +Subject: [PATCH] Optimize ItemStack.isEmpty() + +Remove hashMap lookup every check, simplify code to remove ternary + +diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java +index 911bd879a..45ebd3f61 100644 +--- a/src/main/java/net/minecraft/server/ItemStack.java ++++ b/src/main/java/net/minecraft/server/ItemStack.java +@@ -120,9 +120,15 @@ public final class ItemStack { + this.F(); + } + ++ // Paper start - optimize isEmpty ++ private static Item airItem; + public boolean isEmpty() { +- return this == ItemStack.a ? true : (this.item != null && this.item != Item.getItemOf(Blocks.AIR) ? (this.count <= 0 ? true : this.damage < -32768 || this.damage > '\uffff') : true); ++ if (airItem == null) { ++ airItem = Item.REGISTRY.get(new MinecraftKey("air")); ++ } ++ return this == ItemStack.a || this.item == null || this.item == airItem || (this.count <= 0 || (this.damage < -32768 || this.damage > '\uffff')); + } ++ // Paper end + + public static void a(DataConverterManager dataconvertermanager) { + dataconvertermanager.a(DataConverterTypes.ITEM_INSTANCE, (DataInspector) (new DataInspectorBlockEntity())); +-- +2.12.0.windows.1 + |