Paper/Spigot-Server-Patches/0366-Optimize-Captured-TileEntity-Lookup.patch
Shane Freeder 8e972bf5aa
Updated Upstream (Bukkit/CraftBukkit/Spigot)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
bf1fa3e3 Update to Minecraft 1.15.1

CraftBukkit Changes:
30a1b691 Update to Minecraft 1.15.1
e2790ae2 Remove outdated build delay.

Spigot Changes:
2ee05fef Update to Minecraft 1.15.1
2019-12-17 22:39:07 +00:00

36 lines
1.5 KiB
Diff

From ce387ed73b42b470bffc930031a18ced0b092f0d Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
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 45389f2ab..f59bdd1b9 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1016,12 +1016,13 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
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.tickingTileEntities) {
tileentity = this.e(blockposition);
--
2.24.1