2018-01-11 06:31:19 +01:00
|
|
|
From c949ff1e8360b6c7a27a4e31ed5e9c78a9b71b5d Mon Sep 17 00:00:00 2001
|
2016-12-21 10:21:42 +01:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
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
|
2018-01-11 06:31:19 +01:00
|
|
|
index a8f7ff98..9465f4c1 100644
|
2016-12-21 10:21:42 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
2017-12-19 23:56:13 +01:00
|
|
|
@@ -143,9 +143,15 @@ public final class ItemStack {
|
2016-12-21 10:21:42 +01:00
|
|
|
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()));
|
|
|
|
--
|
2018-01-11 06:31:19 +01:00
|
|
|
2.14.3
|
2016-12-21 10:21:42 +01:00
|
|
|
|