Paper/Spigot-Server-Patches/0382-Optimize-Captured-TileEntity-Lookup.patch
Zach Brown 70ce6ce831
Move version command update checking to the implementation
This makes it easier for downstream projects (forks) to replace the
version fetching system with their own. It is as simple as implementing
an interface and overriding the default implementation of
org.bukkit.UnsafeValues#getVersionFetcher()

It also makes it easier for us to organize things like the version
history feature.

Lastly I have updated the paper implementation to check against the site
API rather than against jenkins.
2019-05-27 04:13:41 -05:00

36 lines
1.5 KiB
Diff

From 4ade6daf8cd140e254b7959c7a3ccef5b30b6dad 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 4280fdf80..6a36c4467 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -1049,12 +1049,13 @@ public abstract class World implements IIBlockAccess, GeneratorAccess, AutoClose
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.B(blockposition);
--
2.21.0