From c36f2062091622baf6307e35e60e389f47abf451 Mon Sep 17 00:00:00 2001 From: Aikar Date: Sat, 6 Apr 2019 10:25:21 -0400 Subject: [PATCH] Optimize Captured TileEntity Lookup upstream was doing a containsKey/get pattern, and always doing it at that. that scenario is only even valid if were in the middle of a block place. Optimize to check if the captured list even has values in it, and also to just do a get call since the value can never be null. --- ...-Optimize-Captured-TileEntity-Lookup.patch | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Spigot-Server-Patches/0436-Optimize-Captured-TileEntity-Lookup.patch diff --git a/Spigot-Server-Patches/0436-Optimize-Captured-TileEntity-Lookup.patch b/Spigot-Server-Patches/0436-Optimize-Captured-TileEntity-Lookup.patch new file mode 100644 index 000000000..41b0ecde1 --- /dev/null +++ b/Spigot-Server-Patches/0436-Optimize-Captured-TileEntity-Lookup.patch @@ -0,0 +1,35 @@ +From 746b2dc3bcd9c7adcce8648dcf5ee18874a5e5cb Mon Sep 17 00:00:00 2001 +From: Aikar +Date: Sat, 6 Apr 2019 10:16:48 -0400 +Subject: [PATCH] Optimize Captured TileEntity Lookup + +upstream was doing a containsKey/get pattern, and always doing it at that. +that scenario is only even valid if were in the middle of a block place. + +Optimize to check if the captured list even has values in it, and also to +just do a get call since the value can never be null. + +diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java +index 0e8025d311..b940f95bdb 100644 +--- a/src/main/java/net/minecraft/server/World.java ++++ b/src/main/java/net/minecraft/server/World.java +@@ -1935,12 +1935,13 @@ public abstract class World implements IEntityAccess, GeneratorAccess, IIBlockAc + return null; + } else { + // CraftBukkit start +- if (capturedTileEntities.containsKey(blockposition)) { +- return capturedTileEntities.get(blockposition); ++ TileEntity tileentity = null; // Paper ++ if (!capturedTileEntities.isEmpty() && (tileentity = capturedTileEntities.get(blockposition)) != null) { // Paper ++ return tileentity; // Paper + } + // CraftBukkit end + +- TileEntity tileentity = null; ++ //TileEntity tileentity = null; // Paper - move up + + if (this.J) { + tileentity = this.E(blockposition); +-- +2.21.0 +