aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0351-Optimize-Captured-TileEntity-Lookup.patch
blob: dae998240b3b4c98a6dbb90db99e92271ca3eb83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
From 0000000000000000000000000000000000000000 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 86636d09699bff4c0c90b8b484df03668b8d5584..3fc33d410e62fa8f86dd7f912e0ae483e48697f1 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -945,12 +945,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.D(blockposition);